Javatpoint Logo
Javatpoint Logo

C++ Vector back()

It gives a reference to the last element.

cpp vector back() function

Syntax

Consider a vector v.Syntax would be:

Parameter

This function does not contain any parameter.

Return value

This function returns the last element of vector

Example

Let's see a simple example.

Output:

banana

In this example, back() function displays the last element of the vector named 'fruit'.






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