title: Why are my C++ pointers suddenly diverging?
body: <p>I'm creating a small AVL tree class in C++, and I'm getting a bit mixed up with pointers here, and its acting rather strangely.</p>
  <p>In the class, <strong>I have a variable named &quot;root&quot;, which is a pointer to a node</strong>. At one point, I pass a pointer of this object into the following function:</p>
  <pre><code>template &lt;class T&gt; void AVL&lt;T&gt;::RRotate(Node ** node) {
      std::cout &lt;&lt; this-&gt;root &lt;&lt; std::endl &lt;&lt; *node &lt;&lt; std::endl;
      *node = (*node)-&gt;left;      
      std::cout &lt;&lt; this-&gt;root &lt;&lt; std::endl &lt;&lt; *node;
  }
  </code></pre>
  <p>(Note that 'left' is a field that contains a pointer to a node).</p>
  <p>Now, the first print is always printing out the same memory location.</p>
  <p>However, the second call will print a different directory for this-&gt;root and *node.</p>
  <p>Why is this? When I set &quot;*node = (*node)-&gt;left;&quot;, shouldn't it be changing this-&gt;root too, since node is just a pointer to that pointer?</p>
  <p>I'm a tad confused.</p>
  <p>Any help is appreciated!</p>
  <p><strong>EDIT:</strong> A sample output is as follows:</p>
  <blockquote>
  <p>0x902a88</p>
  <p>0x902a88</p>
  <p>0x902a88</p>
  <p>0x902aa8</p>
  </blockquote>
  <p><strong>EDIT 2:</strong> Printing out &amp;this-&gt;root and node instead reveals that they're always the same value, so it looks like the pointer is pointing to the right place.</p>