Advertisement
evcamels

lr-6-2

Nov 23rd, 2020
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.37 KB | None | 0 0
  1.  
  2.  
  3. #include <iostream>
  4. #include <list>
  5. using namespace std;
  6. class person{
  7. public:
  8.     virtual void show() = 0;
  9.     virtual void add() = 0;
  10.     list <string> a;
  11.     list <string> :: iterator i;
  12.     void s(){
  13.         for(i = a.begin(); i!=a.end();i++){
  14.         cout << (*i) << endl;
  15.     }
  16.     }
  17. };
  18. class employee : public person{
  19. protected:
  20.     void add() override{
  21.         a.push_back("Служащий");
  22.     }
  23.     void show() override{
  24.         for(i = a.begin(); i!=a.end();i++){
  25.             cout << (*i) << endl;
  26.         }
  27.     }
  28. };
  29. class worker : public person{
  30. protected:
  31.     void add() override{
  32.         a.push_back("Рабочий");
  33.     }
  34.     void show() override{
  35.      for(i = a.begin(); i!=a.end();i++){
  36.             cout << (*i) << endl;
  37.         }
  38.     }
  39. };
  40. class engeneer : public person{
  41. protected:
  42.     void add() override{
  43.         a.push_back("Инженер");
  44.     }
  45.     void show() override{
  46.         for(i = a.begin(); i!=a.end();i++){
  47.             cout << (*i) << endl;
  48.         }
  49.     }
  50. };
  51. class person1{
  52. public:
  53.     void show(person *p){
  54.         p->show();
  55.     }
  56.     void add(person *ad){
  57.         ad->add();
  58.     }
  59. };
  60. int main() {
  61.     employee e;
  62.     worker w;
  63.     engeneer en;
  64.     person1 per;
  65.     per.add(&e);
  66.     per.show(&e);
  67.     per.add(&w);
  68.     per.show(&w);
  69.     per.add(&en);
  70.     per.show(&en);
  71.     return 0;
  72. }
  73.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement