title: Does a const reference class member prolong the life of a temporary?
body: <p>Why does this:</p>
  
  <pre><code>#include &lt;string&gt;
  #include &lt;iostream&gt;
  using namespace std;
  
  class Sandbox
  {
  public:
      Sandbox(const string&amp; n) : member(n) {}
      const string&amp; member;
  };
  
  int main()
  {
      Sandbox sandbox(string("four"));
      cout &lt;&lt; "The answer is: " &lt;&lt; sandbox.member &lt;&lt; endl;
      return 0;
  }
  </code></pre>
  
  <p>Give output of:</p>
  
  <blockquote>
    <p>The answer is:</p>
  </blockquote>
  
  <p>Instead of:</p>
  
  <blockquote>
    <p>The answer is: four</p>
  </blockquote>