title: How is its lifetime of a return value extended to the scope of the calling function when it is bound to a const reference in the calling function?
body: <p>"If you return a value (not a reference) from the function, then bind it to a const reference in the calling function, its lifetime would be extended to the scope of the calling function."</p>
  
  <p>So: CASE A</p>
  
  <pre><code>const BoundingBox Player::GetBoundingBox(void)
  {
      return BoundingBox( &amp;GetBoundingSphere() );
  }
  </code></pre>
  
  <p>Returns a value of type <code>const BoundingBox</code> from function <code>GetBoundingBox()</code></p>
  
  <p>variant I: (Bind it to a const reference)</p>
  
  <pre><code>const BoundingBox&amp; l_Bbox = l_pPlayer-&gt;GetBoundingBox();
  </code></pre>
  
  <p>variant II: (Bind it to a const copy)</p>
  
  <pre><code>const BoundingBox l_Bbox = l_pPlayer-&gt;GetBoundingBox();
  </code></pre>
  
  <p>Both work fine and I don't see the <code>l_Bbox</code> object going out of scope. (Though, I understand in variant one, the copy constructor is not called and thus is slightly better than variant II).</p>
  
  <p>Also, for comparison, I made the following changes.</p>
  
  <p>CASE B</p>
  
  <pre><code>BoundingBox Player::GetBoundingBox(void)
  {
      return BoundingBox( &amp;GetBoundingSphere() );
  }
  </code></pre>
  
  <p>with Variants:
  I</p>
  
  <pre><code>BoundingBox&amp; l_Bbox = l_pPlayer-&gt;GetBoundingBox();
  </code></pre>
  
  <p>and II:</p>
  
  <pre><code>BoundingBox l_Bbox = l_pPlayer-&gt;GetBoundingBox();
  </code></pre>
  
  <hr>
  
  <p>The object <code>l_Bbox</code> still does not go out scope. How does "bind it to a const reference in the calling function, its lifetime would be extended to the scope of the calling function", really extend the lifetime of the object to the scope of the calling function ?</p>
  
  <p>Am I missing something trivial here?</p>