

InterviewSolution
1. |
Write a C++ to read and display information about employees and managers. Employee is a class that contains employee number, name, address ad department. Manager class contains all information of the employee class and a list of employees working under a manager. |
Answer» #include <iostream.h> #include<conio.h> class employee { public: int num,house ; char city[20], state[20], name[20],depart[20]; public: void input() { cout<<"Enter the employe's name"; cin>>name;\ cout<<"Enter the employe number"; cin>>num; cout<<"Enter the address including house number ,city ,state"; cin>>house>>city>>state; cout<<"enter the department"; cin>>depart; } void output() { cout<<"\nemploye's infomation:"; cout<<"\n"<<name<<"\n"<<num<<"\n"<<"address -:" <<"\n"<<house<<" "<<city<<"\n"<<state; cout<<"\n"<<depart; } }; class manager: public employee { char name[20]; int n ,i; public: void getdata() { cout<<"Enter the manager's name"; cin>>name; cout<<"enter the total number of employe's working under him"; cin>>n; } void info(); }; void manager::info() { getdata(); for(i=1;i<=n;i++) { input(); } cout<<name; cout<<"\nemploye's are-:n" ; for(i=1;i<=n;i++) { cout<<i<<" employe-:" ; output(); } } void main() { class manager M; clrscr(); M.info(); getch(); } |
|