title: About passing a temporary object to a const reference
body: <p>In the book by Andrew Koenig, Accelerated C++, he shows the following code:</p>
  
  <pre><code>vector&lt;double&gt; emptyvec()
  {
      vector&lt;double&gt; v;    // no elements
      return v;
  }
  
  grade(midterm, final, emptyvec());
  </code></pre>
  
  <p>Now, grade function takes a const reference to <code>vector&lt;double&gt;</code>. This means to me that the temporary object returned by the emptyvec() should be copied because it is created in the stack as a local variable and aliasing that seems strange to me. How exactly this works? Also on another page, he passes a const reference to a function that takes its arguments by value and modifies them. Can a const reference of <code>vector&lt;double&gt;</code> be passed to a function whose parameter expects <code>vector&lt;double&gt;</code>?</p>