fork download
  1. #include <iostream>
  2.  
  3. class A{
  4. public:
  5. virtual int DoSomething() {return 0;}
  6. int f()
  7. {
  8. DoSomething();
  9. return 0;
  10. }
  11. };
  12.  
  13. class B: public A
  14. {
  15. public:
  16. int DoSomething() {
  17. std::cout << "Hello World!" << std::endl;
  18. return 0;
  19. }
  20. };
  21.  
  22. int main() {
  23. A* a = new B;
  24. a->f();
  25. delete a;
  26. return 0;
  27. }
Success #stdin #stdout 0s 4576KB
stdin
Standard input is empty
stdout
Hello World!