I'm having a little trouble with Copy Constructor.
I have a class, which contains two structures, and two pointers to the first structure ( let's just say I'm having a Linked List of first structure, and each contains a linked list of the second structure ). They all seem to work fine. But ...
When I make another instance of the class using the copy constructor ( does a deep copy, every element is copied, so each instance has it's own linked lists ) using
MyClass a,b;
// Operations with a
b ( a );
it all works ok. But then...
MyClass a,b;
// Operations with a
b = a;
also seems to work, but then my destructor goes amok, and tries to free some element multiple times, sending this:
* Error in `./a.out': double free or corruption (!prev): 0x000000000258a540 *
along with ==Backtrace== and ==Memory Map==, ending killing my program by SIGABRT signal.
So, when the copy constructor works fine and is present, what is wrong with assignment? Should I override the operator= ?