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