title: What does it mean to return a reference?
body: <p>I understand the concept of references in C++, and I understand what they do when used in function parameters, but I am still very much confused on how they work with return types.</p>
  
  <p>For example, when used in parameters, this code:</p>
  
  <pre><code>int main (void) {
    int foo = 42;
    doit(foo);
  }
  
  void doit (int&amp; value) {
    value = 24;
  }
  </code></pre>
  
  <p>is similar to this code:</p>
  
  <pre><code>int main (void) {
    int foo = 42;
    doit(&amp;foo);
  }
  
  void doit (int* value) {
    *value = 24;
  }
  </code></pre>
  
  <p>(knowing that the compiler will automatically put an asterisk in front of <em>value</em> every time it is used in the first code sample of <em>doit</em>, but in the latter you'd have to put the asterisk in yourself every time you try to use <em>value</em>)</p>
  
  <p>So when used as a reference what does this next code (using reference in a return type) translate to? Does it return a pointer to an int? Or would it just return an int?</p>
  
  <pre><code>int main (void) {
    int* foo = /*insert useful place in memory*/;
    foo = doit(foo);
  }
  
  int&amp; doit (int* value) {
    //insert useful code
  }
  </code></pre>