I've read in C++ primer plus thats says
implementations have the option of handling this statement in two steps: using the copy constructor to create a temporary object and then using assignment to copy the values to the new object.That is, initialization always invokes a copy constructor, and forms using the = operator may also invoke an assignment operator
And I've also read on some websites that says code like A a2 = a1;
is the same as A a2(a1);
, which means A a2 = a1
only invokes the copy constructor.
So my question is that when the program uses only copy constructor and when it uses both copy constructor and assignment operator. And who decides that, is it compiler?