C++ reference pointing to a temporary variable?
<pre><code>class ClassB {
    int m_b;
public:
    ClassB(int b) : m_b(b) {}
    void PrintClassB() const {
        cout &lt;&lt; "m_b: " &lt;&lt; m_b &lt;&lt; endl;
    }
};


int main(int argc, char* argv[])
{
    const ClassB &amp;af = ClassB(1);
    af.PrintClassB(); // print m_b: 1 with vs2008 &amp; gcc 4.4.3
}
</code></pre>

<p>Given the above code, I have difficulties to understand this snippet:</p>

<p>Q1> What does this line mean?</p>

<pre><code>const ClassB &amp;af = ClassB(1);
</code></pre>

<p>Here is my understanding:</p>

<blockquote>
<pre><code>af refers to a temporary variable ClassB(1) and after the
</code></pre>
  
  <p>execution of this line, the temporary variable is destroyed and af
  refers to an undefined variable. During this procedure, no
  copy-constructor is called.</p>
</blockquote>

<p>Then why we can still issue the following statement and obtain the results?</p>

<pre><code>af.PrintClassB(); // print m_b: 1 with vs2008 &amp; gcc 4.4.3
</code></pre>
