C++ Deque insert()

C++ Deque insert() function inserts new element just before the specified position pos and the size of the container increases by the number of elements are inserted. Insertion of an element can be done either from front or from the back.

Syntax

Parameter

pos: Position before which the new element is to be inserted.

val: New value to be inserted.

n: Number of times the value to be inserted.

(first,last): It defines the range of the elements which are to be inserted.

Return value

It returns an iterator to the newly constructed element.

Example 1

Let's see a simple example

Output:

java C++ .net C 

In this example, insert() function inserts new element i.e "C++" at the second position.

Example 2

Let's see a simple example

Output:

1 5 5 2 3 4 

In this example, insert() function inserts '5' element twice at second and third position.


Next TopicC++ Deque



Latest Courses