Solved - problem with constructor
Matthew Flaschen and Michael Burr pointed out a problem of an overloaded Node(int) constructor calling Node() , which does not work because ... Thanks guys!
I created a program (I am debugging it) and faced with some strange problem ... the operation `if` does not start when it should be ... This is a school project in which we must build an AVL Tree with at least one" optimizing "function.
I am sure and experienced that the work of `rdown` and` ldown` (as balancing factors) - the tree is not perfectly balanced. Rather, it is based on the height of the branches (i.e., `` Balance () `should only return (1,0, -1), otherwise it will be unbalanced.
I hope this is enough to solve this strange problem ... I have never encountered anything similar before with Microsoft Visual Studio 2010.
Node struct:
struct Node { int data;
Problem Finder
Node * AVL_Tree::search(const Node * num) { Node * tmpNode = AVL_Tree::root; // tmpNode is a place holder for the search for (int i = 1; true; i++) { // increment int i to check for excess searching -> pervents endless loop if (tmpNode == NULL) //****** causing problems******** // the search has reached a dead end (the data is not contained) ==> NULL return NULL; if (tmpNode->data == num->data) // if the data of num is the same as tmpNode the data is contained ==> Node * return tmpNode; // since the node has not been found yet move down the tree... if (tmpNode->data > num->data && tmpNode->lchild != NULL) // if the data is smaller than the tmpNode move to the lchild tmpNode = tmpNode->lchild; else if (tmpNode->rchild != NULL) // since the node has been proven to not be = to the data to be searched for tmpNode = tmpNode->rchild; // and it is not smaller... move to the right if (i > (root->ldown + 1) && i > (root->rdown + 1) ) { // the while loop has searched suffecent time and has not ended string tmp = "the search incountered a critical error... aborting..."; // to prevent an endless loop the string error throw tmp; // is thrown (should not happen) - indicates a broken tree } } }
Screenshot of the first meeting with for loop

Screenshot of the second meeting with for loop
If you mark on the βAutoβ tab at the bottom that all the data and the node address itself are NULL , but in the next screenshot it continues 
The program continues !!! what? >
I pressed the F-10 button (the "go to the next command" button) ... and it jumps right over the expression? What for? 
c ++ null if-statement visual-studio-2010
Wallter
source share