beginner reference type parameter confusion
<pre><code>foo(int &amp;bar)
{
    bar = 5;
}
</code></pre>

<p>The call to this function would be</p>

<pre><code>int foobar = 2;

foo(foobar);
</code></pre>

<p>Am I right in thinking that the function parameter essentially 'gets' the memory address of the variable, but does not then have to be dereferenced in foo, and that I would be changing the original value of foobar? Before this I was under the Impression that you would have to pass in a memory address like this:</p>

<pre><code>foo(&amp;foobar);
</code></pre>

<p>and then use the variable inside foo like this:</p>

<pre><code>*bar = 5;
</code></pre>

<p>Am I right in thinking that this is wrong? I think, like a lot of beginners, the confusion came from thinking that a reference was like a pointer in that it held a memory address, but it's never really a type is it? Just an operator.</p>
