samedi 23 septembre 2017

What happens when a copy-ctor is getting called?

Suppose our code is:

A a1();
A a2(a1);

What happens exactly at the second line? As far as I understand, a reference to a1 is passed to the copy-ctor which in turns makes a shallow-copy (suppose default).

What I want to validate is that no other copy or memory allocating is done. Even in the case of A a2{A()}; (where the copy-ctor copies from a temporary object)

Thanks

Aucun commentaire:

Enregistrer un commentaire