fork download
  1. #include <iostream>
  2. using std::cout;
  3. using std::endl;
  4.  
  5. struct Base
  6. {
  7. virtual void f(int) { cout << "Base::f(int)" << endl; }
  8. virtual void f(double){ cout << "Base::f(double)" << endl; }
  9. };
  10. struct Derived : public virtual Base
  11. {
  12. using Base::f;
  13. virtual void f(int) { cout << "Derived::f(int)" << endl; }
  14. };
  15.  
  16. int main()
  17. {
  18. Base b;
  19. Derived d;
  20. Base *pb = new Derived;
  21. Base &dr (d);
  22.  
  23. b.f(1.0);
  24. d.f(1.0);
  25. pb->f(1.0);
  26. dr.f(1.0);
  27.  
  28. delete pb;
  29. }
  30.  
Success #stdin #stdout 0s 2984KB
stdin
Standard input is empty
stdout
Base::f(double)
Base::f(double)
Base::f(double)
Base::f(double)