Is this a copy? but why it works like a reference?
<p>The below code, <code>Value r = foo(i)</code>, is <code>r</code> a reference or a copy?</p>

<pre><code>Value foo(int i) {
  return Value::New(i);
}

Value bar(Arg x) {
  // should I use Value&amp; r = foo(x.getIndex());
  Value r = foo(x.getIndex());
  x.close();
  return r;
}
</code></pre>

<hr>

<p>I tested</p>

<pre><code>#include &lt;stdio.h&gt;
using namespace std;

class Value {
public:
    Value() {
        printf("construct\n");
    }
};

Value foo(){
    Value a;
    return a;
}

Value bar() {
    Value b = foo();
    return b;
}

int main(){
    Value c = bar();
}
</code></pre>

<p>only construct 1 times.</p>
