PDA

View Full Version : Vectors of pointers (C++)



Moon Rabbits
03-22-2008, 06:08 AM
How do I free the memory allocated for a vector of pointers? Because using the erase() function only deletes the vector entry, not the actual pointer. What is an efficient way to go about doing this?

o_O
03-23-2008, 04:35 AM
You could loop through the vector and call delete(*element) (or free(), remove() or erase() :p) on each element.