fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. class Base
  5. {
  6. public: virtual void BaseMethod()
  7. {
  8. cout << "Written by base." << endl;
  9. }
  10. };
  11. class Delivered : public Base
  12. {
  13. public: void BaseMethod()
  14. {
  15. Base::BaseMethod();
  16. cout << "Written by delivered." << endl;
  17. }
  18. };
  19. int main() {
  20. Base * base = new Base();
  21. Base * delivered = new Delivered();
  22.  
  23. base->BaseMethod();
  24.  
  25. cout << endl;
  26.  
  27. delivered->BaseMethod();
  28. // your code goes here
  29. return 0;
  30. }
Success #stdin #stdout 0s 3456KB
stdin
Standard input is empty
stdout
Written by base.

Written by base.
Written by delivered.