Use of reference in C++ -


I am writing code to solve the "recovery binary search tree" problem.

Tree node * first; Tree node * second; Zero recovery (tree node * root) {inOrder (root); Int temporarily = first-> Val First- gt; Val = sec-> Val Second-> Val = Temporary; Return; } Zero in order (tree_node * root) {if (root!) Returns; Inorder (root-> left); If (! Ex) {east = root; } And (if (pre-> gtc-> gtc-> root-> val) {if (before!) First = pre; second = root;} pre = root;} in order (root-> right) ;}};

It works fine and past all tests and then I was thinking that the three pointers outside the function should not be defined, then I wrote something like this Class solution {public: zero recovery (TreeNode * root) {TreeNode * pre; tree node * first; tree node * second; inorder (root, pre, first, sec ); Inert Temporary = First-> Val = First- gt; Val = sec-> Val; Second-> Val = Temporary; Return;} Zero Inorder (TreeNode * Root, TreeNode * and Pre, TreeNode * And first, tree_node * and seconds) {if (root!) Returns; inorder (root-> left, east, first, second); if (! Pre) {east = root;} and (if (pre-> Val & gt; Root- & gt; Val) {if (! First) first = pre; second = root;} pre = root;} in order (root-> right, east, first, second);}};

but this does not work Does what is wrong in my use of terms or anything else has made a mistake?


Comments

Popular posts from this blog

HTML/CSS - Automatically set height width from background image? -

php - Mysql Show Process - Sleep Commands and what to do -

c - What is the address of buf (the local variable in the main function)? -