fork download
  1. #include <iostream>
  2.  
  3. class Base
  4. {
  5. public:
  6. virtual void methodA()=0;
  7. void methodB()
  8. {
  9. this->methodA();
  10. }
  11. };
  12.  
  13. class Derivated: public Base
  14. {
  15. public:
  16. virtual void methodA()
  17. {
  18. std::cout << "A" << std::endl;
  19. }
  20. };
  21.  
  22. int main()
  23. {
  24. Derivated d;
  25. d.methodB();
  26.  
  27. Base* b=new Derivated;
  28. b->methodB();
  29. delete b;
  30. return 0;
  31. }
Success #stdin #stdout 0s 2984KB
stdin
Standard input is empty
stdout
A
A