Javatpoint Logo
Javatpoint Logo

C++ queue front() Function

C++ Queue front() function returns the value of the front element of the queue. The first element is the oldest element or the element which was initially added to the queue. The function is used to return that element.

Syntax

Parameters

The function does not take any parameter, it is only used to return the value of the oldest element or the element at the front end of the queue.

Return value

The function returns the front element of the queue.

Example 1

Output:

newqueue.front() is modified to 44

Example 2

Output:

11

Complexity

The complexity of the function is constant.

Data races

The function accesses the container. The queue container as a whole is accessed, and then the element which is the oldest is returned.

Exception Safety

Guarantee as equivalent to the operations that are performed on the underlying container object is provided.

Next TopicC++ Queue





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA