< Previous | Contents | Next >

Using the pop_back() Member

Function

I remove the heros shield using

inventory.pop_back();

The pop_back() member function removes the last element of a vector and reduces the vector size by one. In this case, inventory.pop_back() removes "shield" from inventory because that was the last element in the vector. Also, the size of inventory is reduced from 3 to 2.