< Previous | Contents | Next >

Using the clear() Member

Function

Next I simulate the act of a thief robbing the hero of all of his items.

inventory.clear();

The clear() member function removes all of the items of a vector and sets its size to 0. After the previous line of code executes, inventory is an empty vector.