I have a base class A and a derived class B:
class A { public: virtual f(); }; class B : public A { public: B() { p = new char [100];
try this:
class A { public: virtual ~A() {} virtual f(); }; class B : public A { public: B() { p = new char [100]; } virtual ~B() // virtual keywork optional but occasionally helpful for self documentation. { delete [] p; } f(); private: char *p; };