mercredi 16 août 2017

reassigning a new object to a static type object in C++

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

f()
{
   static 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(10,0) get destroyed automatically when I call V(5,0) and assign it to v in the second line ? Or do I have to destroy it ?

Since v is static, is the object V(5,0) retained across function calls ?

Aucun commentaire:

Enregistrer un commentaire