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