C++ list pop_back() Function
Example
Remove the last element of a list:
list<string> cars = {"Volvo", "BMW", "Ford", "Mazda"};
cars.pop_back();
for (string car : cars) {
cout << car << "\n";
}
Definition and Usage
The pop_back() function removes the last element of a list.
It does not return the removed element. Use back() first if you need its value.
The pop_back function is defined in the <list> header file.
Syntax
list.pop_back();
Parameter Values
None.
Technical Details
| Returns: | Nothing (void). |
|---|
Related Pages
Read more about lists in our List Tutorial.