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