C++ destructor memory leak
问题 Relatively simple question about handling destructors properly... First I've got a class that's something like this: class Foo { public: ReleaseObjects() { for (std::map<size_t, Object*>::iterator iter = objects.begin(); iter != objects.end(); iter++) { delete (*iter).second; } objects.clear(); } private: std::map<size_t,Object*> objects; } So the function simply deletes the objects, which were created using 'new'. Problem is an Object class: class Bar : public Object { public: Bar() { baz =