fork download
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. class A
  6. {
  7. public:
  8. virtual void foo() {
  9. cout << "A" << endl;
  10. }
  11. };
  12.  
  13. class B : public A
  14. {
  15. public:
  16. void foo(...)
  17. {
  18. cout << "B" << endl;
  19. }
  20. };
  21.  
  22. class C : public B
  23. {
  24. public:
  25. void foo(...)
  26. {
  27. cout << "C" << endl;
  28. }
  29. };
  30.  
  31.  
  32. int main()
  33. {
  34. C c;
  35. B* b = &c;
  36. b->foo();
  37.  
  38. return 0;
  39. }
Success #stdin #stdout 0s 3296KB
stdin
Standard input is empty
stdout
B