I would like to know exactly which function is invoked when you declare an object in this fashion:
Object newObjectName = existingObject;
I've always thought that the above statement used Copy constructor. Some student in my class claimed that the above statement is a 2-step process - Default Constructor for creating newObjectName and then assignment operator to copy the value of existingObject. Is that true?
I created a test code below. When I delete the default assignment operator (Change default to delete), I do not get an error on Line 35, which tells me that Line 35 does not utilize the assignment operator. But if I delete the default copy constructor, I do get an error on Line 35. This test tells me that the copy constructor is being used for Line 35, but I'd like to know what you think.
The copy constructor is called whenever an object is initialized from another object of the same type (unless overload resolution selects the move constructor as a better match), which includes
direct initializationT a(b);, where b is of type T;