fork download
  1. #include <iostream>
  2.  
  3. class IA
  4. {
  5. public:
  6. virtual void error() = 0;
  7. virtual void n() { error(); }
  8. };
  9.  
  10. class X : public IA
  11. {
  12. public:
  13. void error()override {std::cout << "X error" << std::endl;}
  14. void notify() { IA::n(); }
  15. };
  16.  
  17. class Y : public IA
  18. {
  19. public:
  20. void error() override{std::cout << "Y error" << std::endl;}
  21. };
  22.  
  23. int main()
  24. {
  25. std::cout << "Hello world!" << std::endl;
  26.  
  27. X x;
  28. Y y;
  29. x.notify();
  30.  
  31. return 0;
  32. }
  33.  
  34.  
Success #stdin #stdout 0.01s 5304KB
stdin
45
stdout
Hello world!
X error