Single Inheritance

in Hindi - Single Inheritance




Source Code :

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

class Employee{
    
protected:
int emp_id;
char emp_name[20];
int emp_salary;

public:
void getdata()
{
cout<<" Enter Employee id ";
cin>>emp_id;
cout<<" Enter Employee name ";
cin>>emp_name;
cout<<" Enter Employee salary ";
cin>>emp_salary;
}
void putdata()
{
cout<<"Employee id : "<<emp_id<<endl;
cout<<"Employee name : "<<emp_name<<endl;
cout<<"Employee salary : "<<emp_salary<<endl;
}
};

class fitness : public Employee
{
protected:
float height,weight;

public:
void accept()
{
cout<<"Enter Height in feet: ";
cin>>height;
cout<<"Enter Weight in kg: ";
cin>>weight;
}
void display()
{
cout<<"Employee Height is "<<height<<" feet"<<endl;
cout<<"Employee Weight is "<<weight<<" kg"<<endl;
}
};

int main(){
fitness F;
cout<<" Enter Employee details ";
F.getdata();
F.accept();
cout<<"Employee details are ";
F.putdata();
F.display();

return 0;
}