Javatpoint Logo
Javatpoint Logo

C++ List reverse()

C++ List reverse() function reverses the order of the elements in the list container.

Syntax

Parameter

It does not contain any parameter.

Return value

It does not return any value.

Example 1

Let's see a simple example when the list contains integer value.

Output:

content of list li is : 123456
After reversing, content of list li is : 654321

In this example, reverse() function reverses the content of the list li and the output is 654321.

Example 2

Let's see a simple example when the list contains string.w

Output:

content of list li is : mango is a fruit
After reversing, content of list li is : fruit a is mango

In this example, reverse() function reverses the list of the string and the output is "fruit a is mango".


Next Topicsort() Function



Help Others, Please Share

facebook twitter pinterest