C++ basic constructors/vectors problem (1 constructor, 2 destructors)
<p>Question is probably pretty basic, but can't find out what's wrong (and it leads to huge of memleaks in my app):</p>

<pre><code>class MyClass {
public:
    MyClass() { cout &lt;&lt; "constructor();\n"; };
    MyClass operator= (const MyClass&amp; b){ 
        cout &lt;&lt; "operator=;\n"; return MyClass(); 
    };
    ~MyClass() { cout &lt;&lt; "destructor();\n"; };
};

main() {
 cout &lt;&lt; "1\n";
 vector&lt;MyClass&gt; a;
 cout &lt;&lt; "2\n";
 MyClass b;
 cout &lt;&lt; "3\n";
 a.push_back(b);
 cout &lt;&lt; "4\n";
}
</code></pre>

<p>The output is:</p>

<pre><code>1
2
constructor();
3
4
destructor();
destructor();
</code></pre>

<ol>
<li>Why are there 2 destructors? </li>
<li>If it's because a copy is created to be inserted into vector - how come "operator=" is never called?</li>
</ol>
