fork download
  1. class Base {
  2. public:
  3. static Base* getInstance();
  4. virtual ~Base() {};
  5. protected:
  6. Base() {};
  7. };
  8.  
  9. class Derived : public Base {};
  10.  
  11. // Implementation
  12. Base* Base::getInstance() { return new Derived(); }
  13.  
  14. int main() {
  15. Base::getInstance();
  16. };
Success #stdin #stdout 0s 2980KB
stdin
Standard input is empty
stdout
Standard output is empty