< Previous | Contents | Next >
I remove the hero’s 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.