Copy-constructor is called when a new object is created from an existing object, as a copy of the existing object. And assignment operator is called when an already initialized object is assigned a new value from another existing object.
a2 = a1; // calls assignment operator, same as "a2.operator=(a1);"
A a3 = a1; // calls copy constructor, same as "A a3(a1);"
Войдите чтобы поставить Нравится
Войдите чтобы прокомментировать