fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. struct A
  5. {
  6. void f() { std::cout << "A::f()\n"; }
  7. };
  8.  
  9. struct B : public A
  10. {
  11. void f() { std::cout << "B::f()\n"; }
  12. };
  13.  
  14. int main()
  15. {
  16. B b;
  17.  
  18. b.f();
  19. static_cast<A&>(b).f();
  20.  
  21. return 0;
  22. }
Success #stdin #stdout 0s 3340KB
stdin
Standard input is empty
stdout
B::f()
A::f()