#include <iostream>
#include <memory>
using namespace std;
class Base {
protected:
~Base() {
cout << "B\n";
}
};
class Derived : public Base {
public:
virtual ~Derived(){
cout << "D\n";
}
};
int main() {
std::shared_ptr<Base> myBaseS(new Derived());
//std::unique_ptr<Base> myBaseU(new Derived());
// Base *myBase_raw = new Derived();
// delete myBase_raw;
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8bWVtb3J5Pgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKY2xhc3MgQmFzZSB7Cglwcm90ZWN0ZWQ6Cgl+QmFzZSgpIHsKCQljb3V0IDw8ICJCXG4iOwoJfQp9OwoKY2xhc3MgRGVyaXZlZCA6IHB1YmxpYyBCYXNlIHsKCXB1YmxpYzoKCXZpcnR1YWwgfkRlcml2ZWQoKXsKCQljb3V0IDw8ICJEXG4iOwoJfQp9OwoKCmludCBtYWluKCkgewoJCglzdGQ6OnNoYXJlZF9wdHI8QmFzZT4gbXlCYXNlUyhuZXcgRGVyaXZlZCgpKTsKCS8vc3RkOjp1bmlxdWVfcHRyPEJhc2U+IG15QmFzZVUobmV3IERlcml2ZWQoKSk7CgkKLy8JQmFzZSAqbXlCYXNlX3JhdyA9IG5ldyBEZXJpdmVkKCk7Ci8vCWRlbGV0ZSBteUJhc2VfcmF3OwoJCglyZXR1cm4gMDsKfQ==