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

Assignment No:5 Program Name

The document describes a C++ program that uses inheritance to model employee data. It defines classes for Person, Account, Admin, and Master, with Master inheriting from Account and Admin. The classes store employee name, code, pay, and experience. Methods are defined to input and display data for each class. The main function prompts the user to input data for a Master object and displays it, allowing updates in a loop.

Uploaded by

Monalisha Sinha
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views3 pages

Assignment No:5 Program Name

The document describes a C++ program that uses inheritance to model employee data. It defines classes for Person, Account, Admin, and Master, with Master inheriting from Account and Admin. The classes store employee name, code, pay, and experience. Methods are defined to input and display data for each class. The main function prompts the user to input data for a Master object and displays it, allowing updates in a loop.

Uploaded by

Monalisha Sinha
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 3

/** Assignment No:5

Program Name: Program using inheritance

Person

Name, code

Admin
Account
experience
pay

Master

Name,
code,
experienc
e, pay

Date: 23/02/11 **/

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

class person
{
protected:
char name[20],code[10];
public:
void input1();
void display1();
};

class account : virtual public person


{
protected:
float pay;
public:
void input2();
void display2();
};

class admin : virtual public person


{
protected:
char experience[30];
public:
void input3();
void display3();
};

class master : public account,public admin


{
char name[20],code[10],experience[30];
float pay;
public:
void display();
};

void person :: input1()


{
cout<<"Enter the name and code of the employee:"<<endl;
cin>>name>>code;
}

void person :: display1()


{
cout<<"Name of the employee: "<<name<<endl;
cout<<"Code of the employee: "<<code<<endl;
}

void account :: input2()


{
cout<<"Enter the salary amount: "<<endl;
cin>>pay;
}

void account :: display2()


{
cout<<"Salary of the employee: "<<pay<<endl;
}

void admin :: input3()


{
cout<<"Enter the experience year: "<<endl;
cin>>experience;
}

void admin :: display3()


{
cout<<"Year of experience of the employee: "<<experience<<" year"<<endl;
}

void master :: display()


{
display1();
display2();
display3();
}

int main()
{
master m;
int option;
clrscr();
do
{
m.input1();
m.input2();
m.input3();
m.display();
cout<<"Do you want to update?"<<endl;
cout<<"If yes enter 1 otherwise enter 0."<<endl;
cin>>option;
}
while(option);
getch();
return 0;
}

/***************************OUTPUT****************************

Enter the name and code of the employee:


Ria
e2o71
Enter the salary amount:
25000
Enter the experience year:
2003
Name of the employee: Ria
Code of the employee: e2o71
Salary of the employee: 25000
Year of experience of the employee: 2003 year
Do you want to update?
If yes enter 1 otherwise enter 0.
1
Enter the name and code of the employee:
Puja
e2072
Enter the salary amount:
35000
Enter the experience year:
2005
Name of the employee: Puja
Code of the employee: e2072
Salary of the employee: 35000
Year of experience of the employee: 2005 year
Do you want to update?
If yes enter 1 otherwise enter 0.

******************************************************************/

You might also like