fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. class A {
  5. public:
  6. virtual string Identify() = 0;
  7. virtual string D_Work() { throw; } // If it's not defined, throw
  8. };
  9.  
  10. class B : public A {
  11. public:
  12. string Identify() {return "B"; }
  13. };
  14.  
  15. class D : public B {
  16. public:
  17. string D_Work() {return "D_Work"; }
  18. };
  19.  
  20. int main() {
  21. A *d = new D;
  22. std::cout << d->D_Work();
  23.  
  24. return 0;
  25. }
Success #stdin #stdout 0s 4284KB
stdin
Standard input is empty
stdout
D_Work