title: Attempting to implement find in avl tree
body: <p>I'm using this code <a href="https://rosettacode.org/wiki/AVL_tree#C.2B.2B" rel="nofollow">https://rosettacode.org/wiki/AVL_tree#C.2B.2B</a> as a basis for an AVL tree. By default the example uses integers however I need to store strings. So I modified the code to debug mainly making the root public and trying to print the values.</p>
  
  <pre><code>22 /* AVL tree */
   23 template &lt;class T&gt;
   24 class AVLtree {
   25         public:
   26                 AVLtree(void);
   27                 ~AVLtree(void);
   28                 bool insert(T key);
   29                 void deleteKey(const T key);
   30                 void printBalance();
   31                 AVLnode&lt;T&gt; *root;
   32 
   33         private:
   34 
   35                 AVLnode&lt;T&gt;* rotateLeft          ( AVLnode&lt;T&gt; *a );
   36                 AVLnode&lt;T&gt;* rotateRight         ( AVLnode&lt;T&gt; *a );
   37                 AVLnode&lt;T&gt;* rotateLeftThenRight ( AVLnode&lt;T&gt; *n );
   38                 AVLnode&lt;T&gt;* rotateRightThenLeft ( AVLnode&lt;T&gt; *n );
   39                 void rebalance                  ( AVLnode&lt;T&gt; *n );
   40                 int height                      ( AVLnode&lt;T&gt; *n );
   41                 void setBalance                 ( AVLnode&lt;T&gt; *n );
   42                 void printBalance               ( AVLnode&lt;T&gt; *n );
   43                 void clearNode                  ( AVLnode&lt;T&gt; *n );
   44 };
  ..................................
  247 int main(void)
  248 {
  249         AVLtree&lt;std::string&gt; t;
  250 
  251         std::cout &lt;&lt; "Inserting integer values 1 to 10" &lt;&lt; std::endl;
  252         for (int i = 1; i &lt;= 10; ++i)
  253                 t.insert(i+" ");
  254 
  255         std::cout &lt;&lt; "Printing balance: ";
  256         t.printBalance();
  257         std::cout &lt;&lt; t.root-&gt;key + "\n";
  258         std::cout &lt;&lt; t.root-&gt;left-&gt;key + "\n";
  259         std::cout &lt;&lt; t.root-&gt;left-&gt;right-&gt;key + "\n";
  260         std::cout &lt;&lt; t.root-&gt;key;
  261 
  262 }
  </code></pre>
  
  <p>however the problem is that the result that prints out is</p>
  
  <pre><code>Inserting integer values 1 to 10
  Printing balance: 1 0 -1 0 0 1 0 0 1 0 
  ing balance: 
  Printing balance: 
  g balance: 
  ing balance: 
  </code></pre>
  
  <p>And I have no idea why.</p>