C++ Vector operator=()Last Updated : 17 Mar 2025 This function assigns new values to the vector container and replacing old ones. SyntaxConsider two vectors 'v' and 'v1'. Syntax would be : Here, the values of v1 vector are assigned to the vector v2. Parameterv1:v1 is a vector object. Return valueIt returns *this. Example 1Let's see a simple example. Output: C# In this example, values of v vector are assigned to the vector v1 using operator= () function. Example 2Let'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 |
We request you to subscribe our newsletter for upcoming updates.

We deliver comprehensive tutorials, interview question-answers, MCQs, study materials on leading programming languages and web technologies like Data Science, MEAN/MERN full stack development, Python, Java, C++, C, HTML, React, Angular, PHP and much more to support your learning and career growth.
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India