English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

C++ Deque push_back() Usage and Example

C++ Deque (Double-Ended Queue)

C ++ The Deque push_back() function adds a new element to the end of the deque container, and the size of the container increases by one.

Syntax

void push_back(value_type val);

Parameter

val:The new value to be inserted at the end of the deque container.

Return Value

It does not return any value.

Example1

Let's see a simple example

#include <iostream>
#include<deque>
using namespace std;
int main()
{
    deque<int> d={10,20,30,40};
    deque<int>::iterator itr;
    d.push_back(50);
    for(itr=d.begin();itr!=d.end();++itr)
    cout <<*itr << " \t ";
    return 0;
  }

Output:

10 20 30 40 50

In this example, the push_back() function adds a new element to the end of the deque, that is50.

C++ Deque (Double-Ended Queue)