C++ Language/Std/Stl/CollectionClasses/SequenceCollections/Vector/RemovingItems

From Wikibooks, open books for an open world
Jump to navigation Jump to search

The erase() function removes an iterator-specified item from the vector, but doesn't do anything to that removed item. So if the item-type was a pointer, then you would still be responsible for any manual destruction of the actual object.

To remove all items, use clear().

To remove the last item, use pop_back().

Additional information about removing items from a vector (includes interactive examples)