Similar Problems

Similar Problems not available

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.

Syntax

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;

QUE.push(1);

QUE.push(4);

QUE.push(3);

QUE.push(7);

cout << QUE.back();

return 0;

}

Output

7