Reputation: 1268
In this code:
class myClass
{
...
vector<myThing> thing(10);
vector<myStuff> stuff(10);
...
}
vector<myClass> vecClass(10);
...
vecClass.clear(); /// calls destructor on myClass instances
Each element of vecClass
holds 10 element vectors of thing and stuff. When clear()
is called, does that make thing and stuff go out of scope, and thus be destroyed properly? Or is there something explicit that I have to do?
Upvotes: 3
Views: 290
Reputation: 181735
Yes, their destructors will be called. There is nothing else you need to do here.
Upvotes: 11