class Base {
public:
static Base* getInstance();
virtual ~Base() {};
protected:
Base() {};
};
class Derived : public Base {};
// Implementation
Base* Base::getInstance() { return new Derived(); }
int main() {
Base::getInstance();
};
Y2xhc3MgQmFzZSB7CnB1YmxpYzoKICBzdGF0aWMgQmFzZSogZ2V0SW5zdGFuY2UoKTsKICB2aXJ0dWFsIH5CYXNlKCkge307CnByb3RlY3RlZDoKICBCYXNlKCkge307Cn07CgpjbGFzcyBEZXJpdmVkIDogcHVibGljIEJhc2Uge307CgovLyBJbXBsZW1lbnRhdGlvbgpCYXNlKiBCYXNlOjpnZXRJbnN0YW5jZSgpIHsgcmV0dXJuIG5ldyBEZXJpdmVkKCk7IH0KCmludCBtYWluKCkgewpCYXNlOjpnZXRJbnN0YW5jZSgpOwp9Ow==