Program
#include
#include “conio.h”
#include “iostream.h”
class base
{
public:
char nam[20],dofb[20];
float bp,gp;
void getdata();
};
class derived:public base
{
float da,hra,pf;
public:
void calculate();
void display();
};
void base::getdata()
{
cout << "\n\n\t enter the name:\t"; cin >> nam;
cout << "\n\n\t enter the date of birth:\t"; cin >> dofb;
cout << "\n\n\t enter the basic pay:\t"; cin >> bp;
}
void derived::calculate()
{
da=bp*0.12;
hra=bp*0.07;
pf=400;
gp=bp+da+hra+pf;
}
void derived::display()
{
cout << "\n\n\t NAME :\t" << size="5">Output
FRIEND FUNCTION
INPUT:
Enter the name :Lancy
Enter the date of birth :18-08-88
Enter the basic pay :25000
OUTPUT:
NAME :Lancy
DOB :18-08-88
BASIC PAY :25000
DA :3000
HRA :1750
PF :400
GROSS PAY :30150