C++ Deque operator=()

C++ Deque operator=() function assigns new contents to the container and replacing the current content of same type. Size of the deque can be modified accordingly.

Syntax

Parameter

x: It is a deque container whose content is to be copied into an another deque object.

Return value

It returns *this.

Example 1

Let's see a simple example

Output:

1 2 3 4 5 

In this example, operator=() assigns the content of 'a' container to 'b' container.

Example 2

Let's see a simple example when both the deques are of different type.

Output:

error: no matching function for call to 'std::deque<char>::operator=(std::deque<int>&)'

In this example, type of 'a' and 'b' are different. Therefore, operator=() function throws an error.


Next TopicC++ Deque