I'm writing a binary tree and having some problems. In my delete method, I return 1 if the root is the only node in the tree and it is deleted and a 0 in every other case. When I run the program, for some reason in a certain case, I get the value of 163920. Here's the code for that case:
Code:
if(right == NULL && left == NULL)
{
BTN *t = this;
if(parent == NULL)
{
delete t;
return 1;
}
/*int lorr = parent->lorr(name);
if(lorr == 1)
{
parent->left = NULL;
//parent = NULL;
delete t;
}
else
{
parent->right = NULL;
//parent = NULL;
delete t;
}*/
delete t;
return 0;
}
The node I'm trying to delete ought to return 0. Does having that "delete t;" mess with the return? Any help is greatly appreciated.
Tagged by Salem - next time, read http://cboard.cprogramming.com/misc....bbcode#buttons