Hi,
I'm trying to run a program I have coded that has the following setup:
There is a tree containing "player" objects.
Each "player" object has a linked list containing "weapon" objects.
Each "weapon" object has a stack containing "round" objects.
I need to set it up so that of you delete the tree object, all the players within the tree are deleted, which in turn deletes all the weapons in each player's linked list, which in turn deletes all the rounds in each weapons stack in a cascade effect.
The destructor for the tree looks like this:
Tree::~Tree(void)
{
cout << "Tree Deleted" << endl << endl;
delete this->root;
}
The destructor for the player class:
Player::~Player(void)
{
cout << "Player Deleted" << endl << endl;
delete this->weapons;
delete this->leftChild;
delete this->rightChild;
}
The destructor for the linked list class:
LinkedList::~LinkedList(void)
{
while(!isEmpty())
{
delete Delete();
}
}
The destructor for the weapon class:
Weapon::~Weapon(void)
{
cout << "Weapon Deleted" << endl << endl;
delete this->magazine;
}
The destructor for the stack class:
Stack::~Stack(void)
{
while(this->top != -1)
{
delete this->Pop();
}
}
The destructor for the round class:
Round::~Round(void)
{
cout << "Round Deleted" << endl << endl;
}
When I run the program, the cascade begins and the output shows:
Tree Deleted
Player Deleted
Weapon Deleted
Round Deleted
Round Deleted
And then BOOM, this error message pops up and the program halts:
Image added as attatchment.
Any ideas on what is going wrong???
James