fork download
  1. #include<iostream>
  2.  
  3. class a
  4. {
  5. public:
  6. virtual void add()
  7. { std::cout << "in A"; }
  8.  
  9. void fn()
  10. { add(); }
  11. };
  12.  
  13. class b: public a
  14. {
  15. public:
  16. virtual void add() override
  17. { std::cout << "in b"; }
  18. };
  19.  
  20. int main()
  21. {
  22. b d;
  23. d.fn();
  24. }
  25.  
Success #stdin #stdout 0s 3296KB
stdin
Standard input is empty
stdout
in b