I have a vector of Object pointers. I want to be able to delete those objects and free the memory taken up by those objects.
What I have currently is this:
This is the vector that contains the object pointers:
std::vector<Ball*> List;
This is the function that deletes the element in the vector and frees the memory:
void BallManager::DeleteBall(int id)
{
List[id]->~Ball(); //Not sure if this is needed
delete List[id];
List[id] = NULL;
List.erase(List.begin()+id);
}
My question is do I need to also call the destructor for the object or is that taken care of by delete?
erasewould deallocate the memory and everything as well. - chris