#include <iostream>
using namespace std;
class LeakyBase{
public:
~LeakyBase(){}
};
class PluggedBase{
public:
virtual ~PluggedBase(){}
};
class LeakyDerived : public LeakyBase{
public:
LeakyDerived() { cout << "LeakyDerived()" << endl; }
~LeakyDerived() { cout << "~LeakyDerived()" << endl; }
};
class PluggedDerived : public PluggedBase{
public:
PluggedDerived() { cout << "PublicDerived()" << endl; }
~PluggedDerived() { cout << "~PluggedDerived()" << endl; }
};
int main()
{
LeakyBase * l = new LeakyDerived;
PluggedBase * p = new PluggedDerived;
delete l;
delete p;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgoKdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCmNsYXNzIExlYWt5QmFzZXsKcHVibGljOgoJfkxlYWt5QmFzZSgpe30KfTsKCmNsYXNzIFBsdWdnZWRCYXNlewpwdWJsaWM6Cgl2aXJ0dWFsIH5QbHVnZ2VkQmFzZSgpe30KfTsKCmNsYXNzIExlYWt5RGVyaXZlZCA6IHB1YmxpYyBMZWFreUJhc2V7CnB1YmxpYzoKCUxlYWt5RGVyaXZlZCgpIHsgY291dCA8PCAiTGVha3lEZXJpdmVkKCkiIDw8IGVuZGw7IH0KCX5MZWFreURlcml2ZWQoKSB7IGNvdXQgPDwgIn5MZWFreURlcml2ZWQoKSIgPDwgZW5kbDsgfQp9OwoKY2xhc3MgUGx1Z2dlZERlcml2ZWQgOiBwdWJsaWMgUGx1Z2dlZEJhc2V7CnB1YmxpYzoKCVBsdWdnZWREZXJpdmVkKCkgeyBjb3V0IDw8ICJQdWJsaWNEZXJpdmVkKCkiIDw8IGVuZGw7IH0KCX5QbHVnZ2VkRGVyaXZlZCgpIHsgY291dCA8PCAiflBsdWdnZWREZXJpdmVkKCkiIDw8IGVuZGw7IH0KfTsKCmludCBtYWluKCkKewoJTGVha3lCYXNlICogbCA9IG5ldyBMZWFreURlcml2ZWQ7CglQbHVnZ2VkQmFzZSAqIHAgPSBuZXcgUGx1Z2dlZERlcml2ZWQ7CgkKCWRlbGV0ZSBsOwoJZGVsZXRlIHA7Cn0K