I have a class that has a std::list as a member variable. I also have a vector of these classes. If I delete an element from the vector, will the class destructor be called on the deleted instance? Do I have to explicitly clear my list with list::clear() in the destructor?
class my_class {
string class_name;
list<int> my_list;
public:
my_class();
~my_class(); // destructor
};
vector<my_class> my_vec;
my_class obj1, obj2, obj3;
my_vec.push_back(obj1);
my_vec.push_back(obj2);
my_vec.push_back(obj3);
my_vec.erase(my_vec.begin()+2); //Is this sufficient?