Single inheritance is defined as the inheritance in which a derived class is inherited from the only one base class.

Where ‘A’ is the base class, and ‘B’ is the derived class.
Single Level Inheritance Example: Inheriting Fields
When one class inherits another class, it is known as single level inheritance. Let’s see the example of single level inheritance which inherits the fields only.
#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
In the above example, Employee is the base class and Programmer is the derived class.


