What is the best way to store pointers in C++. The number of pointers is dynamic, so an array is not feasible. C++'s vector is not the obvious solution, as deleting anything off the vector would cause a memory leak. Subclassing vector to properly delete pointers is not feasible either, as vector's destructor is not virtual. Is there any other option to creating my own vector (a proper pain to do).
If you erase a member of the vector, you'd definitely have to delete the (dynamically allocated) pointer first. I'm not sure how that's any more of a pain than creating your own vector class. You're right about not subclassing an STL container. I don't know of an easy way out.