#include <iostream>
using namespace std;
class clsA {
public:
clsA() { cout << "clsA\n"; }
~clsA() { cout << "~clsA\n"; }
};
class dlvA : public clsA {
public:
dlvA() { cout << "dlvA\n"; }
~dlvA() { cout << "~dlvA\n"; }
};
class clsB {
public:
clsB() { cout << "clsB\n"; }
virtual ~clsB() { cout << "~clsB\n"; }
};
class dlvB : public clsB {
public:
dlvB() { cout << "dlvB\n"; }
~dlvB() { cout << "~dlvB\n"; }
};
int main() {
{
cout << "(1)\n";
dlvA objA;
}
{
cout << "(2)\n";
dlvB objB;
}
cout << "(3)\n";
clsA* ptrA = new dlvA;
delete ptrA;
cout << "(4)\n";
clsB* ptrB = new dlvB;
delete ptrB;
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKY2xhc3MgY2xzQSB7CnB1YmxpYzoKCWNsc0EoKSB7IGNvdXQgPDwgImNsc0FcbiI7IH0KCX5jbHNBKCkgeyBjb3V0IDw8ICJ+Y2xzQVxuIjsgfQp9OwoKY2xhc3MgZGx2QSA6IHB1YmxpYyBjbHNBIHsKcHVibGljOgoJZGx2QSgpIHsgY291dCA8PCAiZGx2QVxuIjsgfQoJfmRsdkEoKSB7IGNvdXQgPDwgIn5kbHZBXG4iOyB9Cn07CgpjbGFzcyBjbHNCIHsKcHVibGljOgoJY2xzQigpIHsgY291dCA8PCAiY2xzQlxuIjsgfQoJdmlydHVhbCB+Y2xzQigpIHsgY291dCA8PCAifmNsc0JcbiI7IH0KfTsKCmNsYXNzIGRsdkIgOiBwdWJsaWMgY2xzQiB7CnB1YmxpYzoKCWRsdkIoKSB7IGNvdXQgPDwgImRsdkJcbiI7IH0KCX5kbHZCKCkgeyBjb3V0IDw8ICJ+ZGx2QlxuIjsgfQp9OwoKCmludCBtYWluKCkgewoJewoJCWNvdXQgPDwgIigxKVxuIjsKCQlkbHZBIG9iakE7Cgl9Cgl7CgkJY291dCA8PCAiKDIpXG4iOwoJCWRsdkIgb2JqQjsKCX0KCQoJY291dCA8PCAiKDMpXG4iOwoJY2xzQSogcHRyQSA9IG5ldyBkbHZBOwoJZGVsZXRlIHB0ckE7CgkKCWNvdXQgPDwgIig0KVxuIjsKCWNsc0IqIHB0ckIgPSBuZXcgZGx2QjsKCWRlbGV0ZSBwdHJCOwoJCglyZXR1cm4gMDsKfQ==