queue::front() 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::front() is a C++ Standard Library function which is used to get the first element of a queue.

Syntax

Queue_Name.front( );

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

Return value: The queue::front() function returns the reference the first element of the queue container.

Example of queue::front() Function

Program

#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.front(); 
    return 0; 
} 

Output

1

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