C++ Programming Blog

 
 
 

Image

 #include<iostream.h>
 #include<conio.h>


 //------------------------------  base  ---------------------------------//


 class base
    {
       public:
        void show()  { cout<<\"base class\"<<endl;  }
    };


 //-----------------------------  derv_1  --------------------------------//


 class derv_1:public base
    {
       public:
        void show()  { cout<<\"derv_1 class\"<<endl;  }
    };


 //------------------------------  derv_2  -------------------------------//


 class derv_2:public base
    {
       public:
        void show()  { cout<<\"derv_2 class\"<<endl;  }
    };


 main()
    {
       clrscr();

       base b_obj;

       b_obj.show();

       derv_1 d_1_obj;
       derv_2 d_2_obj;

       d_1_obj.show();
       d_2_obj.show();

       getch();
       return 0;
    }

 
 
Didn't find what you were looking for? Find more on Program to illustrate an example of Polymorphism