0% found this document useful (0 votes)
80 views3 pages

1.write A Program To Implement Inheritance Shown Below Figure - Assume Suitable Member Function

Uploaded by

shambhupawar293
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
80 views3 pages

1.write A Program To Implement Inheritance Shown Below Figure - Assume Suitable Member Function

Uploaded by

shambhupawar293
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Practical No:11

Exercise:
1.Write a program to implement inheritance shown below figure.Assume suitable member
function.

#include<iostream.h>
#include<conio.h>
class furniture
{
char material[20];
float price;
public:
void getdata()
{
cout<<"\n Enter the material:";
cin>>material;
cout<<"\n Enter the price:";
cin>>price;
}
void putdata()
{
cout<<"\n Material is:"<<material;
cout<<"\n Price is:"<<price;
}
};
class table:public furniture
{
float height,surface;
public:
void accept()
{
cout<<"\n table details:";
cout<<"\n Enter the height:";
cin>>height;
cout<<"\n Enter the surface:";
cin>>surface;
}
void display()
{
cout<<"\n height is:"<<height;
cout<<"\n surface is:"<<surface;
}
};
void main()
{
table t;
clrscr();
t.getdata();
t.accept();
t.putdata();
t.display();
getch();
}
Output:

2.Write a program to define class “Employee”.having data members


emp_no,emp_name,emp_designation.

#include<iostream.h>
#include<conio.h>
class employee
{
int emp_no;
char emp_name[20],emp_designation[20];
public:
void input()
{
cout<<"\n Enter the employee no:";
cin>>emp_no;
cout<<"\n Enter the employee name:";
cin>>emp_name;
cout<<"\n Enter the desidnation of employee:";
cin>>emp_designation;
}
void output()
{
cout<<"\n Employee no is:"<<emp_no;
cout<<"\n Employee name is:"<<emp_name;
cout<<"\n Employee designation:"<<emp_designation;
cout<<"\n************************************";
}
};
class salary:public employee
{
float basic,hra,da,gross_sal;
public:
void accept()
{
cout<<"\n Enter the basic salary:";
cin>>basic;
}
void calculate()
{
hra=(15*basic)/100.0;
da=(44.5*basic)/100.0;
gross_sal=basic+da+hra;
cout<<"\n Basic salary:"<<basic;
cout<<"\n HRA:"<<hra;
cout<<"\n DA:"<<da;
cout<<"\n Gross salary:"<<gross_s;
}
};
void main()
{
salary s;
clrscr();
s.input();
s.accept();
s.output();
s.calculate();
getch();
}

Output:

You might also like