Javatpoint Logo
Javatpoint Logo

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.



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


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.


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

Help Others, Please Share

facebook twitter pinterest