/* */ Click to Join Live Class with Shankar sir Call 9798158723

What is Single Inheritance ?


when the parent class has only one child class.In other word, when base class have formed only one derived class is knows as Singal Inheritance .

syntax :

class Base
{
    // BODY OF THE BASE CLASS
};
    class Derived : acess_specifier Base
{
   // BODY OF THE DERIVED CLASS
};
Q1.) Example of Single Inheritance .
    
    
    #include < iostream>  
using namespace std;  
 class Account {  
   public:    
   float salary = 60000;   
 };  
   class Programmer: public Account {  
   public:  
   float bonus = 5000;    
   };       
int main(void) {  
     Programmer p1;  
     cout<<"Salary: "<< p1.salary<< endl;    
     cout <"Bonus: "<< p1.bonus << endl;    
    return 0;  
}  

Output
Salary: 60000
Bonus: 5000