Sunday, 8 September 2013

a pointer to a class that contains pointers

a pointer to a class that contains pointers

hi i have a class that contains pointers,the class iherits nothing
class MyClass
{
public:
MyClass();
~MyClass();
private:
//i have pointers here
};
MyClass::~MyClass()
{
print("destroyed..");
}
now i have to use this class as a pointer in vector like this:
vector<MyClass*> classes;
//push some classes in here but
//when i remove an element
classes.remove(index);
//the destructor doesn't get called,and i think that is the true definition
//of memory leak,
so how do i make it call the destructor

No comments:

Post a Comment