Easy learning with example program codes

CPP Queue

Queue is a data structure in CPP that works on FIFO (First In First Out) technique, which means that the first inserted element will be deleted first in a queue.


template<class T, class Container = deque<T> > class queue;

Member Types of CPP Queue:

container_type To specify underlying container type.
const_reference To specify the reference type of constant container.
size_type To specify the size range of the elements.
value_type To specify the element type.
reference To specify the reference type of container.


CPP Queue Functions:

back To access the rear element of the queue.
(constructor) To construct a queue container.
empty To test for the emptiness of a queue and to get a true value if the queue is empty.
emplace To insert a new element in the queue above the current rear end element.
front To access the front element of the queue.
push To insert a new element at the rear end of the queue.
pop To delete the element in the queue from the front end.
swap To interchange the contents of two containers in reference.
size To return the size of the queue container, which is a measure of the number of elements stored in the queue.



#include <iostream.h>  
#include <queue.h>  
using namespace std;  
void display(queue <int> ds)  
queue <int> dis = ds;  
while (!dis.empty())  
	cout << dis.front() << " ";  
int main()  
queue <int> getqueue;  
cout << "The Queue element from first to last are  : ";  
cout << "\nThe value of getqueue.size() : " << getqueue.size();  
cout << "\nThe value of getqueue.front() : " << getqueue.front();  
cout << "\nThe value of getqueue.back() : " << getqueue.back();  
cout << "\nThe value of getqueue.pop() : ";  
return 0;  


The Queue element from first to last are : 80 60 50 30                                          
The value of getqueue.size() : 4                      
The value of getqueue.front() : 80                    
The value of getqueue.back() : 30   
The value of getqueue.pop() : 60 50 30
Posted in CPP   

Industrial Training

We offers Placement Oriented Training on Java, Spring, JSF, Hibernate, PHP, AngularJS, Angular 4, PLSQL, Oracle BI Publisher etc. We also provides Online training, please mail us at


We also provides the Development services for Website Development , Java Development, PHP Development, Android App Development etc. You can contact us on

Copyright © 2019 CodesJava Protection Status SiteMap Reference: Java Wiki