c++ implicit copy constructor and the assignment operator
<p>I have a class defined as follows:</p>

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

using namespace std;

class Point
{
    int x, y;

public:

    Point(int a, int b) : x(a), y(b)
    { 
        std::cout &lt;&lt; "Constructing point ( " &lt;&lt; a &lt;&lt; ", " &lt;&lt; b &lt;&lt; " ) " 
                 &lt;&lt; std::endl;
    }

    Point(const Point&amp; p) : x(p.x), y(p.y)
    {
        std::cout &lt;&lt; "In copy constructor " &lt;&lt; p.x &lt;&lt; " " &lt;&lt; p.y 
                 &lt;&lt; std::endl;
    }

    Point&amp; operator=(const Point&amp; p)
    {
        std::cout &lt;&lt; "In assignment operator " &lt;&lt; p.x &lt;&lt; " " &lt;&lt; p.y 
                 &lt;&lt; std::endl;
        x = p.x;
        y = p.y;
        return *this;
    }
};

int main()
{
    Point p1 = Point(1, 2); 

    return 0;
}
</code></pre>

<p>Now when I execute this all I see is <code>Constructing point (1, 2)</code>. I am assuming that the compiler is doing some optimization here. Is it correct that in theory a temporary gets constructed and then the assignment operator is called to initialize p1?</p>
