experiment with copy construction for a vector
<p>While trying to experiment with copy construction by 'pass by value' and the followed destruction, I tried this code:</p>

<pre><code>#include &lt;iostream&gt;
#include &lt;string&gt;
#include &lt;vector&gt;

using namespace std;

class Rock{
int sz;
public:
Rock():sz(0){cout&lt;&lt; "Default ctor"&lt;&lt;endl;}
~Rock(){cout&lt;&lt; "Dtor"&lt;&lt;endl;}
Rock(const Rock&amp; r){ cout &lt;&lt; "Copy ctor" &lt;&lt; endl; sz = r.sz;}
Rock&amp; operator=(const Rock&amp; r) {cout &lt;&lt; "In assignment op" &lt;&lt; endl; sz = r.sz;}
};

int main()
{
vector&lt;Rock&gt; rocks;
Rock a, b, c;
rocks.push_back(a);
rocks.push_back(b);
rocks.push_back(c);
return 0;
}
</code></pre>

<p>And got the below output. Up to line 7 everything is fine, however I could not understand what happens from then on. Can someone clarify?</p>

<pre><code>Default ctor
Default ctor
Default ctor
Copy ctor
Copy ctor
Copy ctor // all fine I got it...
Dtor
Copy ctor
Copy ctor
Copy ctor
Dtor
Dtor
Dtor
Dtor
Dtor
Dtor
Dtor
Dtor
</code></pre>
