fork download
  1. #include <iostream>
  2.  
  3. class Foo
  4. {
  5. public:
  6. virtual void f(short) {
  7. std::cout << "Foo::f" << std::endl;
  8. }
  9. };
  10.  
  11.  
  12. class Bar : public Foo
  13. {
  14. public:
  15. void f(int) {
  16. std::cout << "Bar::f" << std::endl;
  17. }
  18. };
  19.  
  20. int main()
  21. {
  22. Bar b;
  23.  
  24. Foo *x = &b;
  25. x->f(5);
  26. }
Success #stdin #stdout 0s 3340KB
stdin
Standard input is empty
stdout
Foo::f