vector of struct of vector, clear() issue

Hello all,
If I define the following class:
1
2
3
4
5
6
7
class MyClass{
  struct myItem {
     int myInt;
     vector<string> myStr;
 }
 vector<myItem> MyVector;
}


When I call MyVector.clear(), it will handle everything for me or I need to do it myself as follow:
1
2
3
 for (auto& A:WorkingClass.MyVector)
    A.clear();
 WorkingClass.MyVector.clear();


Thanks.

Regds
LAM Chi-fung
MyVector.clear() is enough.
Calling clear on a MyClass::MyVector will call destructors on all of its elements (which call dtors on their elements...) so the contained strings and vectors will delete themselves.
@Peter87 & @tpb, thanks for the clarification.
Topic archived. No new replies allowed.