mercredi 16 août 2017

reconstructing an object in C++ and assigning it to the same type

I have the following piece of code that I have a question about.

V v(10,0);//first argument is size and the second is init val for each element
...
v = V(5,0);

Does the previously allocated v get destroyed automatically when I call V(5,0) and assign it to v in the second line ? Is a new object of type V being created and assigned to v ? I don't fully understand what is happening behind the scene.

Aucun commentaire:

Enregistrer un commentaire