I need help with an arrogant CFile
-
I have a CFile member variable who seems angry with me because doesn't do what I want. Here's the code in MyClass.h: public: CFile* myFile; in MyClass.cpp: CMyClass::CMyClass() { myFile = new CFile; } CMyClass::~CMyClass() { delete myFile; } //My class is derived from CPropertyPage BOOL CMyClass::OnInitDialog() { if (myFile->Open("some.file", CFile::modeRead)) { //Dosomecode myFile->Close(); } } And I get: Debug Assertion Failed! // More things Expression: _BLOCK_TYPE_IS_VALID(pHead->nBlockUse) // More things Since I'm learning C++ and I don't understand what is happening, I need somebody to help me and show that stupid file who is the programmer and not to crash again. Thanks in advance,
-
I have a CFile member variable who seems angry with me because doesn't do what I want. Here's the code in MyClass.h: public: CFile* myFile; in MyClass.cpp: CMyClass::CMyClass() { myFile = new CFile; } CMyClass::~CMyClass() { delete myFile; } //My class is derived from CPropertyPage BOOL CMyClass::OnInitDialog() { if (myFile->Open("some.file", CFile::modeRead)) { //Dosomecode myFile->Close(); } } And I get: Debug Assertion Failed! // More things Expression: _BLOCK_TYPE_IS_VALID(pHead->nBlockUse) // More things Since I'm learning C++ and I don't understand what is happening, I need somebody to help me and show that stupid file who is the programmer and not to crash again. Thanks in advance,
The assertion happens when you delete right? (2b || !2b)
-
The assertion happens when you delete right? (2b || !2b)
-
I have a CFile member variable who seems angry with me because doesn't do what I want. Here's the code in MyClass.h: public: CFile* myFile; in MyClass.cpp: CMyClass::CMyClass() { myFile = new CFile; } CMyClass::~CMyClass() { delete myFile; } //My class is derived from CPropertyPage BOOL CMyClass::OnInitDialog() { if (myFile->Open("some.file", CFile::modeRead)) { //Dosomecode myFile->Close(); } } And I get: Debug Assertion Failed! // More things Expression: _BLOCK_TYPE_IS_VALID(pHead->nBlockUse) // More things Since I'm learning C++ and I don't understand what is happening, I need somebody to help me and show that stupid file who is the programmer and not to crash again. Thanks in advance,
I think you should delete the file pointer not in the window destructor but add an event OnClose and then delete the pointer there, if it doesn't help than u can send me your project to pudaoman@hotmail.com and i'll try to hel you. :rolleyes: