latest Post

C + + part-14 ( inheritance - hierarchical inheritance )








So hey guys what's app so here we are going to say something about the hierarchical inheritance and i were previously defined this term in introduction of the inheritance and i again do this is a type of inheritance in which i say that in this type of inheritance we going to make two sub classes from one major class or you can say that in this type always two or more can be make from the one class.
And you should see our other articles on the C + + so you can  easily understand this one and the links are given below:

ALL THE ARTICLES OF C + +

Let's get straight........................................................................................................................................

HIERARCHICAL INHERITANCE

THIS IS A TYPE OF THE INHERITANCE IN WHICH WE HAVE TWO MAKE TWO SUB CLASSES FROM A SINGLE MAIN CLASS.
THIS IS ALL ABOUT THE THEORY NOW TO THE PRACTICAL I ,MEAN CODE

........................................................................CODE................................................................................

#include<iostream.h>
#include<conio.h>
class emp
{
         protected :
         int id ;
         char name [30] ;
         float sal ;
};
class manager : public emp// public is used so that we can use emp class
{
         float perf_bonus ;
         float total_sal ;
         public :
                          
};
class worker : public emp
{
         int no_of_hrs ;
         double rate_of_interest ;
         double total_sal ;
         public :
                         void input ( )
                         {
                                           cout<<"\n Enter id , name , number of hours , rate of interest ";
                                           cin>>id>>name>>no_of_hrs>>rate_of_interest ;
                         }
                         void display ( ) 
                         {
                                           cout<<"id ="<<id<<"name ="<<name<<"number of hours ="                                                                 <<no_of_hrs<<"rate of interest =<<rate_of_interest<<endl ;
                                           total_sal = sal+no_of_hrs*rste_of_interest ;
                                           cout<<"total salary = "<<total_salary ;                           
                         }
};
void main ( )
{
        worker w ;
        w.input ( ) ;
        w.output ( ) ;
        getch ( ) ;  
}

THANKS FOR YOUR TIME TO THIS ARTICLE
 AND YOU CAN READ MY ANOTHER ARTICLES ALSO 
SO MEET IN THE NEXT ARTICLE .







About hack guru

hack guru
Recommended Posts × +

0 comments:

Post a Comment