title: does returning a vector in c++ append?
body: <p>I am working with vectors in C++ and I came up with the following MWE that I don't quite understand:</p>
  
  <pre><code>#include &lt;iostream&gt;  
  #include &lt;vector&gt;
  
  using namespace std;
  
  vector&lt;double&gt; pb()
  {
      vector&lt;double&gt; a;
      a.push_back(1);
      a.push_back(2);
      a.push_back(3);
      return a;
  }
  
  int main()
  {
      vector&lt;double&gt; asd;
      asd = pb();
      cout &lt;&lt; asd.size() &lt;&lt; endl;
  
      asd = pb();
      cout &lt;&lt; asd.size() &lt;&lt; endl; //WHY DOES THIS GIVE 3, AND NOT 6? asd HAS NOT BEEN EMPTIED AT ANY POINT
  
  
      return 0;
  }
  </code></pre>
  
  <p>What I don't understand is why my vector <code>asd</code> is "initialized" everytime I call <code>pb()</code>. What I would expect was that calling <code>pb()</code> would merely append to the contents of <code>asd</code>.</p>