mercredi 28 juin 2017

Passing argument of object without copy constructor?

I was looking into move semantics in C++11, and got to the part where something like:

SomeClass bar = createSomeClass();     //creates some object of SomeClass
foo(bar);
foo(createSomeClass());

I know that in the first foo the compiler will call SomeClass's copy constructor and the second foo the compiler will call an overloaded move constructor since createSomeClass() returns an R-value.

What if I don't have a copy constructor declared at all? How does the compiler actually know how to copy these objects then?

Aucun commentaire:

Enregistrer un commentaire