fork(1) download
  1. #include <cstdio>
  2.  
  3. class A
  4. {
  5. public:
  6. virtual void vf()
  7. {}
  8. };
  9.  
  10. class B : public A
  11. {
  12. public:
  13. void vf()
  14. {
  15. printf("B::vf\n");
  16. }
  17. };
  18.  
  19. int main()
  20. {
  21. A a;
  22. B b;
  23. b.vf();
  24.  
  25. A* pa= &a;
  26. A* pb= &b;
  27. pa->vf();
  28. pb->vf();
  29. return 0;
  30. }
Success #stdin #stdout 0s 3340KB
stdin
Standard input is empty
stdout
B::vf
B::vf