Question is probably pretty basic, but can\'t find out what\'s wrong (and it leads to huge of memleaks in my app):
class MyClass {
public:
MyClass() { co
When the b object gets pushed onto the vector a copy is made, but not by the operator=() you have - the compiler generated copy constructor is used.
When the main() goes out of scope, the b object is destroyed and the copy in the vector is destroyed.
Add an explicit copy constructor to see this:
MyClass( MyClass const& other) {
cout << "copy ctor\n";
};