Javatpoint Logo
Javatpoint Logo

C++ List emplace_back()

C++ List emplace_back() inserts a new element at the end of the list and the size of the list is increased by one.

The following illustration shows how this function works:

C++ List emplace_back()

Syntax

Parameter

val: New value to be inserted at the end of the list.

Return value

It does not return any value.

Example 1

Let's see a simple example

Output:

1 2 3 4 5

In this example, emplace_back() function adds a new element i.e 5 at the end of the list.

Example 2

Let's see a simple example

Output:

C+
C++

In this example, emplace_back() function adds a new character i.e '+' at the end of the list.





Please Share

facebook twitter google plus pinterest