I have some class in my program.
The class has a method which iterates over an array in order to find some int info.
When it finish the job, it saves the int to a local variable.
But when the program tries to return that variable, suddenly a run-time error occurs and the following message is displayed:
Debug Assertion Failed!
Program: ...a path to my program...
File: f:\dd\vctools\crt\crtw32\misc\dbgdel.cpp
Line: 52
For information on how you program can cause an assertion failure, see the Visual C++ documentation on asserts.
(Press Retry to debug the application)
Does somebody can explain what's the problem?
Also It may be important to know that if instead of calling that function I just write it's code there, everything works fine.
It's very long...
Also It may be important to know that if instead of calling that function I just write it's code there, everything works fine. Pretty weird....
A common problem is when you have a class that has a pointer to some dynamically allocated memory without defining a copy constructor and a copy assignment operator. What happens when you copy such a class is that you end up with two objects with their pointers pointing to the same memory. When one of the objects are destroyed (e.g. dms is destroyed at the end of findFCB) the destructor will deallocate the memory that the pointers pointing to, leaving the other object pointing to memory that is no longer available.