So I get these errors, and I looked everywhere in the net, tried changing lots of stuff but still stuck...
I have a LinkedList with ListNode and the ListNode has a pointer to an object named Candidate. Candidate has a member which is a pointer to an instance of the object Institute.
When my main ends, then destructor for the linked list is being called, and in the destructor i delete all the nodes. Since delete first calls the destructor of the node, in the Node class in the destructor i do this:
class MyLinkedListNode
{
public:
Candidate *nodeCand;
MyLinkedListNode *next;
MyLinkedListNode *prev;
~MyLinkedListNode()
{
delete this -> nodeCand;
}
};
and in Candidate destructor i do this:
Candidate::~Candidate()
{
delete this -> school ;
}
when school is of type Institute*. (Every new candidate has a new institute)
and:
LinkedList::~LinkedList()
{
MyLinkedListNode *curr = this -> _head;
MyLinkedListNode *temp = NULL;
while(curr != NULL)
{
temp = curr;
curr = curr -> next;
remove( temp -> nodeCand );
}
}
and in Institute destructor I do nothing.
Really, I have no idea what I'm doing wrong.