Hello, how can i free up memory in a pointer vector? Here's the code:
class A
{
private:
int x,y,z;
public:
A(param1, param2, param3)
{
x=param1;
y=param2;
z=param3;
}
~A()
{
//prompts an alertbox, warning me about the successful call of the destructor;
}
};
...
vector<A*> list;
list.push_back(new A(1,2,3));
list.erase(list.begin()+index);//SHOULD delete the object from the memory;
list.clear();
I found out that .erase() doesn't free up memory, neither calls the destructor; i tried to use delete
on every list entry with an iteration, but crashes after one iteration. Already checked if the list entry was alredy NULL, to avoid any error.
Am I missing something?
Also, i must use only STL, don't need Boost.