title: C++ Returning Pointers/References
body: <p>I have a fairly good understanding of the dereferencing operator, the address of operator, and pointers in general.</p>
  
  <p>I however get confused when I see stuff such as this:</p>
  
  <pre><code>int* returnA() {
      int *j = &amp;a;
      return j;
  }
  
  int* returnB() {
      return &amp;b;
  }
  
  int&amp; returnC() {
      return c;
  }
  
  int&amp; returnC2() {
      int *d = &amp;c;
      return *d;
  }
  </code></pre>
  
  <ol>
  <li>In <code>returnA()</code> I'm asking to return a pointer; just to clarify this works because <code>j</code> is a pointer?</li>
  <li>In <code>returnB()</code> I'm asking to return a pointer; since a pointer points to an address, the reason why <code>returnB()</code> works is because I'm returning <code>&amp;b</code>? </li>
  <li>In <code>returnC()</code> I'm asking for an address of <code>int</code> to be returned. When I return <code>c</code> is the <code>&amp;</code> operator automatically "appended" <code>c</code>?</li>
  <li>In <code>returnC2()</code> I'm asking again for an address of <code>int</code> to be returned. Does <code>*d</code> work because pointers point to an address?</li>
  </ol>
  
  <p>Assume a, b, c are initialized as integers as Global.</p>
  
  <p>Can someone validate if I am correct with all four of my questions?</p>