Can't understand compiler's behaviour (creating object)
<p>I wrote the following code:</p>

<pre><code>#include &lt;iostream&gt;

class A
{
public:
    A(){ std::cout &lt;&lt; "created" &lt;&lt; std::endl; }
    A(A&amp; other) { std::cout &lt;&lt; "copied" &lt;&lt; std::endl; }
    A&amp; get(){ std::cout &lt;&lt;"got" &lt;&lt; std::endl; return *this; }
    ~A(){ std::cout &lt;&lt; "destroyed" &lt;&lt; std::endl; }
};
</code></pre>

<p>Now, lines</p>

<pre><code>A a = A().get();
</code></pre>

<p>and</p>

<pre><code>A a;    
a = A();
</code></pre>

<p>compile and work correctly, but </p>

<pre><code>A a = A();
</code></pre>

<p>claims:</p>

<pre><code>no matching function for call to ‘A::A(A)’
note: candidates are: A::A(A&amp;)
note:                 A::A()
</code></pre>

<p>And to make things explicit, </p>

<pre><code>A a = (A&amp;)A();
</code></pre>

<p>claims:</p>

<pre><code>error: invalid cast of an rvalue expression of type ‘A’ to type ‘A&amp;’
</code></pre>

<p>I completely don't understand this behaviour.</p>

<p>P.S. I know, that if I make <code>const</code> reference in copy c_tor, everything will be OK.</p>
