There is only one kind of manager in the EMPMULT program in this chapter. Any serious
company has executives as well as managers. From the manager class derive a class
called executive. (We’ll assume an executive is a high-end kind of manager.) The additional data in the executive class will be the size of the employee’s yearly bonus and the
number of shares of company stock held in his or her stock-option plan. Add the appropriate
member functions so these data items can be input and displayed along with the other
manager data.
#include <iostream>
#include <iomanip>
using namespace std;
class Manager{
public:
string name;
int shares,ID;
float bonus=30000;
void getData(){
cout<<"Enter manager ID"<<endl;
cin>>ID;
cout<<"Enter manager name"<<endl;
cin>>name;
cout<<"Enter manager number of shares"<<endl;
cin>>shares;
}
void displayData(){
cout<<ID <<setw(10)<<name<<setw(10)<<shares<<setw(10)<<bonus<<endl;
}
};
class executive:public Manager{
public:
void getData(){
cout<<"Enter execitive ID"<<endl;
cin>>ID;
cout<<"Enter execitive name"<<endl;
cin>>name;
cout<<"Enter execitive number of shares"<<endl;
cin>>shares;
}
void displayData(){
cout<<ID <<setw(10)<<name<<setw(10)<<shares<<setw(10)<<bonus<<endl;
}
};
int main()
{
Manager m;
m.getData();
m.displayData();
executive e;
e.getData();
e.displayData();
return 0;
}
Comments
Leave a comment