Program to implement concept of single inheritance

#include
#include

class emp
{
private:
int eid;
float sal;
public:
void getdata();
void display();
};
class emp_phy:public emp
{
private:
float ht,wt;
public:
void getdata();
void display();
};
void emp::getdata()
{
cout<>eid;
cout<>sal;
}
void emp::display()
{
cout<<"n Employee ID:"<<eid;
cout<<"n Salary:"<<sal;
}

void emp_phy::getdata()
{
emp::getdata();
cout<>wt;
cout<>ht;
}

void emp_phy::display()
{
emp::display();
cout<<"n weight:"<<wt;
cout<<"n height:"<<ht;
}

main()
{
class emp_phy x;
clrscr();
x.getdata();
cout<<"nnn";
cout<<"Entered detail was:";
x.display();
getch();
}

Leave a reply