It is far from clear that you are facing corruption. But I agree that there is some data corruption.
A fairly effective method is to add protective fields around a suspicious field:
... long namecheck1; Artist artist; long namecheck2; ...
Ask the constructor to initialize them for most things, but without knowing the nature of corruption, something non-zero seems more satisfactory.
myclass::myclass() : namecheck1(0x12345678), namcheck2(0x12345678) ...
Add member function consistency check:
void myclass::isokay() { if (namecheck1 != namecheck2 || namecheck2 != 0x12345678) cerr << "the object is corrupted"; ...
Then rewrite the code for calls, especially near suspicious logic. If you are comfortable working with the debugger, put a breakpoint in the error message. By expanding the stack, you can find out what the program has done recently, and collect hints as to which bit of code is likely to be written outside the appropriate boundaries.
wallyk
source share