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'.





Please Share

facebook twitter google plus pinterest

B.Tech / MCA


Learn Latest Tutorials