fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. class Base
  5. {
  6. public:
  7. void g() { f(); }
  8. virtual void f() { cout << "Base::f" << endl; }
  9. };
  10.  
  11. class Derived : public Base
  12. {
  13. public:
  14. Derived() { g(); }
  15. virtual void f() { cout << "Derived::f" << endl; }
  16. };
  17.  
  18. class MoreDerived : public Derived
  19. {
  20. public:
  21. virtual void f() { cout << "MoreDerived::f" << endl; }
  22. };
  23.  
  24. int main()
  25. {
  26. MoreDerived md;
  27. return 0;
  28. }
Success #stdin #stdout 0s 3460KB
stdin
Standard input is empty
stdout
Derived::f