C++ deque push_back() Function
Example
Add an element at the end of a deque:
deque<string> cars = {"Volvo", "BMW", "Ford", "Mazda"};
cars.push_back("Toyota");
for (string car : cars) {
cout << car << "\n";
}
Definition and Usage
The push_back() function adds an element to the end of a deque.
The push_back function is defined in the <deque> header file.
Syntax
deque.push_back(<type> value);
<type> refers to the type of the data that the deque contains.
Parameter Values
| Parameter | Description |
|---|---|
| value | Required. The value of the element to add. |
Technical Details
| Returns: | Nothing (void). |
|---|
Related Pages
Read more about deques in our Deque Tutorial.