Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cstdio>
- class Thing {
- public:
- ~Thing() {
- printf("destroying Thing\n");
- }
- };
- class Base {
- public:
- // without this destructor, Derived is never cleaned up and
- // Thing::~Thing() is never called
- virtual ~Base() {}
- };
- class Derived : public Base {
- public:
- Thing thing;
- };
- int main(int argc, char **argv) {
- Base *b = new Derived;
- delete b;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement