title: C++ pointer assignment
body: <p>Why is <code>90</code> the output value of <code>y</code> and <code>q</code>? I just do <code>p=q</code>. How come the value of <code>q</code> is changed?</p>
  
  <pre><code>int main() 
  {
  
      int x;
      int y;
      int *p = &amp;x;
      int *q = &amp;y;
  
      x = 35;
      y = 46;
  
      p = q;
  
      *p = 90;
  
      cout &lt;&lt; x &lt;&lt; " " &lt;&lt; y &lt;&lt; endl;
      cout &lt;&lt; *p &lt;&lt; " " &lt;&lt; *q &lt;&lt; endl;
      cout &lt;&lt; "Address of p = " &lt;&lt; p &lt;&lt; endl;
      cout &lt;&lt; "Address of q = " &lt;&lt; q &lt;&lt; endl;
  
      return 0;
  }
  </code></pre>
  
  <p>The output is:</p>
  
  <pre><code>35 90
  90 90
  Address of p = 0xbffa83c0
  Address of q = 0xbffa83c0
  </code></pre>