Haval1

inhertance

Mar 23rd, 2019
678
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.17 KB | None | 0 0
  1. #include <iostream>
  2. #include<string>
  3. using namespace std;
  4. int sum=0;
  5. class emp
  6. {
  7.     string name;
  8.     int payrate;
  9. public:
  10.     emp(){
  11.         payrate=0;
  12.         name = "NO NAME";
  13.     }
  14.     void set_emp()
  15.     {
  16.         cout<<"Enter employee name : ";cin>>name;
  17.         cout<<"Enter employee pay rate : ";cin>>payrate;
  18.         sum+=payrate;
  19.     }
  20.     void get_emp()
  21.     {
  22.         cout<<"employee name : "<<name<<endl;
  23.         cout<<"employee pay rate : "<<payrate<<endl;
  24.     }
  25.     void calc()
  26.     {
  27.         float av;
  28.         av = sum /4;
  29.         cout<<"The employee pay rate is : "<<av<<endl;
  30.     }
  31. };
  32. class manager:public emp
  33. {
  34.     string position,duties;
  35. public:
  36.     manager()
  37.     {
  38.         position = duties = "KNOWN";
  39.     }
  40.     void set_m()
  41.     {
  42.         cout<<"Enter manager position : ";cin>>position;
  43.         cout<<"Enter manager duties : ";cin>>duties;
  44.     }
  45.     void get_m()
  46.     {
  47.         cout<<"manager position : "<<position<<endl;
  48.         cout<<"manager duties : "<<duties<<endl;
  49.     }
  50. };
  51. int main()
  52. {
  53.     emp e[4];
  54.     for(int i=0;i<4;i++)
  55.     {
  56.         e[i].set_emp();
  57.     }
  58.     e[0].calc();
  59.     manager m;
  60.     return 0;
  61. }
Advertisement
Add Comment
Please, Sign In to add comment