fork(1) download
  1. #include <iostream>
  2.  
  3. struct Base
  4. {
  5. virtual void f(){std::cout << "Base";}
  6. virtual ~Base() = default;
  7. };
  8.  
  9. struct Derived: Base
  10. {
  11. virtual void f(int){std::cout << "Derived";} // we hide the Base::f()
  12. };
  13.  
  14. int main()
  15. {
  16. Base* pBase = new Derived;
  17. pBase -> f(); // calls Base::f()
  18. delete pBase;
  19. }
Success #stdin #stdout 0s 3228KB
stdin
Standard input is empty
stdout
Base