My program runs, but I am getting this message which I am fairly sure means that I have a memory leak and it is coming from my destructor.
Assignment2(779) malloc: *** error for object 0x100100120: pointer being freed was not allocated
I don't know what I am doing wrong. Since it is a binary search tree I figured while not empty go left if you can't go left go right, if you can't go right, delete. Any tips would be great.
BST::~BST()
{
BinNodePtr parent = 0, temp = myRoot;
while(!empty()){
while(temp->left!='\0'){
parent = temp;
temp = temp->left;
}
while (temp->right!='\0'){
parent = temp;
temp = temp->right;
}
delete temp;
}
}