fork download
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. class Father {
  6. public:
  7. void start () {
  8. this->init();
  9. };
  10.  
  11. virtual void init () {
  12. cout << "I'm the father" << endl;
  13. };
  14. };
  15.  
  16. class Child: public Father {
  17. void init () {
  18. cout << "I'm the child" << endl;
  19. };
  20. };
  21.  
  22. int main (int argc, char** argv) {
  23. Child child;
  24. child.start();
  25. }
Success #stdin #stdout 0.01s 5384KB
stdin
Standard input is empty
stdout
I'm the child