queue::back() function in C++ STL

In C++, the standard library gives us the facility to use the Queues as a type of container adaptors which operate in a first in first out (FIFO) type of arrangement. The queue::back() is a C++ Standard Library function which is used to get the last element of a queue.


Queue_Name.back( );

Parameter: The queue::back() function does not accepts any parameter.

Return value: The queue::back() function returns the reference the last element of the queue container.

Example of queue::back() Function

#include <iostream> 
#include <queue> 
using namespace std; 
int main() 
    queue<int> QUE; 
    cout << QUE.back(); 
    return 0; 



This article is written by

Pratik Singhal

Pratik Singhal

Please comment below, if you have any doubts or find any error in the above article.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top
[gravityforms id="5" description="false" titla="false" ajax="true"]