C++ vector pop_back() function
Example
Remove the last element from a vector:
vector<string> cars = {"Volvo", "BMW", "Ford", "Mazda"};
cars.pop_back();
for (string car : cars) {
cout << car << "\n";
}
Try it Yourself »
Definition and Usage
The pop_back()
function removes the last element from a vector.
Syntax
vector.pop_back();
Parameter Values
None.
Related Pages
Read more about vectors in our Vector Tutorial.