Write a program of single inheritance.
// 1. SINGLE INHERITANCE PROGRAM
#include<iostream.h>
#include<conio.h>
#include<string.h>
class employee
{
public:
int Emp_ID;
char Emp_Name[15];
char Emp_Designation[15];
long int Emp_Salary;
long int Emp_Mobile_No;
};
class employee_section : public employee
{
private:
char Emp_Address[30];
int Emp_Off_days;
public:
void employee_details()
{
cout<<"Enter the ID of the employee::";
cin>>Emp_ID;
cout<<"Enter the name of the employee::";
cin>>Emp_Name;
cout<<"Enter the designation/post of the employee::";
cin>>Emp_Designation;
cout<<"Enter the salary of the employee::";
cin>>Emp_Salary;
cout<<"Enter the mobile no of the employee::";
cin>>Emp_Mobile_No;
cout<<"Enter the address of the employee::";
cin>>Emp_Address;
cout<<"Enter the holidays taken by employees::";
cin>>Emp_Off_days;
}
void display_employee_details()
{
cout<<"\n \n THE DETAILS OF THE EMPLOYEE ARE GIVEN BELOW\n\n"<<endl;
cout<<"The ID of the employee::"<<Emp_ID<<endl;
cout<<"The name of the employee is::"<<Emp_Name<<endl;
cout<<"The designation of the employee is::"<<Emp_Designation<<endl;
cout<<"The salary of the employee is::"<<Emp_Salary<<endl;
cout<<"The mobile number of the employee is::"<<Emp_Mobile_No<<endl;
cout<<"The address of the employee is::"<<Emp_Address<<endl;
cout<<"The holidays taken by the employee::"<<Emp_Off_days<<endl;
}
};
void main()
{
clrscr();
employee_section obj;
obj.employee_details();
obj.display_employee_details();
getch();
}
0 Comments
Have any query? Want any type of module?
Please comment it down and let me know.