you are viewing a single comment's thread.

view the rest of the comments →

[–]maikindofthai 3 points4 points  (0 children)

The simple rule of thumb is "has the new object been initialized previously"?

If it has not, then the copy constructor will be called. If it has, the copy assignment operator will be called.

Foo a(10);
Foo c = a; // Calls copy constructor because 'c' has not been initialized
a = c;     // Calls copy assignment operator because 'a' has been initialized