title: Pointer variable, differences in var and &var
body: <pre><code>#include &lt;iostream&gt;
  
  using namespace std;
  
  int main() {
      int* z = new int(9);
  
      cout &lt;&lt; "address: " &lt;&lt; z &lt;&lt; endl;
      cout &lt;&lt; "value: " &lt;&lt; *z &lt;&lt; endl;
      cout &lt;&lt; "referance: " &lt;&lt; &amp;z &lt;&lt; endl;
      return 0;
  }
  </code></pre>
  
  <p>Looking at the cout values, I was expecting the address and reference to give the same address, but heres what the output is: </p>
  
  <pre><code>address: 0x7fc452c032a0
  value: 9
  referance: 0x7fff5191b8d8
  </code></pre>
  
  <p>Just curious about the reason for this, is the plain value(z) the address of the variable in the heap with a value of 9, where var(&amp;z) is address of the pointer variable which is located in the stack?</p>
  
  <p>Here is a visualization:</p>
  
  <p><a href="https://i.stack.imgur.com/BbdKo.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/BbdKo.png" alt="enter image description here"></a></p>
  
  <p>Is the</p>