fork download
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. struct Base {
  6. virtual void foo(int x) { cout << "int " << x; }
  7. virtual void foo(double x) { cout << "double " << x; }
  8. virtual void foo(char x) { cout << "char " << x; }
  9. };
  10.  
  11. struct Derived : public Base {
  12. virtual void foo(double x) { cout << "DOUBLE " << x; }
  13. };
  14.  
  15. int main()
  16. {
  17. Derived d;
  18. d.foo(7);
  19. return 0;
  20. }
  21.  
Success #stdin #stdout 0.01s 2680KB
stdin
Standard input is empty
stdout
DOUBLE 7