Javatpoint Logo
Javatpoint Logo

C++ Vector operator=()

This function assigns new values to the vector container and replacing old ones.

Syntax

Consider two vectors 'v' and 'v1'. Syntax would be :

Here, the values of v1 vector are assigned to the vector v2.

Parameter

v1:v1 is a vector object.

Return value

It returns *this.

Example 1

Let's see a simple example.

Output:

C#

In this example, values of v vector are assigned to the vector v1 using operator= () function.

Example 2

Let's see a another simple example.

Output:

java

In this example, values of v vector are assigned to the vector v1 using operator=() function and replacing the old contents.

Next TopicC++ Vector




Please Share

facebook twitter google plus pinterest

Learn Latest Tutorials


Preparation


B.Tech / MCA