Consider the following ways of declaring and initializing a variable of type C
:
C c1;
C c2;
c2 = C();
C c3(C());
C c4 = C();
Are all of these completely equivalent to each other, or can some of these differ depending on the exact definition of C
? (assuming it has public default and copy constructors).
These mean:
Note the compiler can elide copy constructor calls. Are they equivalent? - well, it depends on what the copy constructor and assignment operator do.