Javatpoint Logo
Javatpoint Logo

C++ Queue back() Function

C++ Queue function returns the value of the last element of the queue. Here last element is the one that is newest. The element which was most recently added is returned.

Syntax

Parameters

The function does not take any parameters. It is only used to return the value of the last element.

Return value

The function returns the last element of the queue.

Example

Output:

newqueue.back() is modified to 104

Complexity

The complexity of the function is constant.

Data races

The function accesses the container. For returning the last element the whole queue container is accessed and then the value of the newest element is given.

Exception Safety

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

Next TopicC++ Queue




Please Share

facebook twitter google plus pinterest

Learn Latest Tutorials