Hi. I have a vector filled with pointers and I want to delete the pointers. I could do a loop and do delete on all indexes, but my question is that if I just clear the vector. Are the pointers deleted, that is can the memory block that the pointer was pointing to be overwritten?
What do you mean be delete? doing a loop and calling erase on each element would result in the same memory leak as using the clear member function.
You have to use operator delete if you want the heap memory to be recovered and it must be done for every single pointer stored in the vector. Then you can clear the vector with the clear member function or call erase on each element.
boost::ptr_vector<> is the same as std::vector<> except that boost::ptr_vector<> only stores
pointers-to-T and ptr_vector<> automatically calls delete on any pointer removed from
the container, whether it be from an erase() or a clear().