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