Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 724653
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T06:14:50+00:00 2026-05-14T06:14:50+00:00

Who can give me a link for the operator= of vector in MSDN? Why

  • 0

Who can give me a link for the operator= of vector in MSDN?

Why I can only find operator[]?

If operator= is just something default, like copy everything in A to B, how this following code works?

vector<double> v(100,1);
v = vector<double>(200,2);   // if operator= is just a trivail version, how to make sure the old v get cleared? 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T06:14:50+00:00Added an answer on May 14, 2026 at 6:14 am

    std::vector is part of the STL, so any description of std::vector will do. The underlying implementation may differ slightly, but all conformant versions of STL must provide the same interface and the same guarantees for std::vector. I can’t find in quickly on MSDN, but here are two such descriptions of operator=:

    1. http://www.cplusplus.com/reference/stl/vector/operator=/
    2. http://www.sgi.com/tech/stl/Vector.html

    Now, the second part of your question puzzles me. What would you expect operator= to do on a vector if not “copy everything from A into B”?

    In your example, your question was “how to make sure the old v get cleared?”. I can interpret this in one of two ways: You might be asking “how do I know that this assignment v = vector<double>(200,2) will overwrite the contents of v and not append to it?”. The answer is that you know that because that’s the definition of how operator= works for STL containers. Any standards compliant implementation is guaranteed to work that way.

    You might also be asking “what happens to the contents of v when I overwrite them using the assignment v = vector<double>(200,2)?” The answer is that they are deallocated, and if they are objects, their destructors are called. Note the important distinction that if the vector contains pointers to objects, the pointers themselves are deallocated, but not what they point to.

    If I didn’t answer your question, please try to clarify it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

who can give me a simple code , i want a simplest way to
who can give me a short example where i call some system command and
from django.utils.safestring import * print SafeString('\u3042') print '\u3042' \u3042 \u3042 who can give me
print 'xxx' > 'ssaww' it print 'true' who can give me a clear example
(format t ~C ~D ??? var1) Who can give a tip, How/Where in the
is there anyone who can give me a vital and simple explanation im trying
I have searched the Internet and stackoverflow.com, but got nothing. Who can give me
Who can help me to fix the following problem? Here is the issue: in
who can explain code that it's the core of the twitter snowflake. long nextId
Who can help me to translate this XML Schema pattern [0-9]+-([0-9]|K) to java regular

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.