title: Prolonging life of a temporary object using const reference
body: <p>I need a few clarification regarding const reference.
  From <a href="https://stackoverflow.com/questions/12741147/assign-return-value-from-function-to-a-reference-c">this link</a>:<br></p>
  
  <pre><code>const Foo &amp;myFoo = FuncBar();
  </code></pre>
  
  <p>const reference extended the life of the local object. But when I checked <a href="https://stackoverflow.com/questions/2784262/does-a-const-reference-prolong-the-life-of-a-temporary">this link</a> although they used a const reference<br></p>
  
  <pre><code>Sandbox(const string&amp; n) : member(n) {}
  </code></pre>
  
  <p>the lifetime of string "four" did not increase. <br></p>
  
  <pre><code>Sandbox sandbox(string("four"));
  </code></pre>
  
  <p>They used the sentence </p>
  
  <blockquote>
    <p>Only local const references prolong the lifespan.
    <br></p>
  </blockquote>
  
  <p>Then in the second link isn't the string "four" local to the main function and shouldn't the const reference <code>n</code> prolong its life?<br>
  So why isn't the lifetime getting prolonged in the second link? </p>