Advertisement
evcamels

lr-6-5

Nov 23rd, 2020
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.40 KB | None | 0 0
  1.  
  2. #include <iostream>
  3. #include <list>
  4. using namespace std;
  5. class organization{
  6. public:
  7.     virtual void show() = 0;
  8.     virtual void add() = 0;
  9.     list <string> a;
  10.     list <string> :: iterator i;
  11. };
  12. class plant : public organization{
  13. protected:
  14.     void add() override{
  15.         a.push_back("Завод");
  16.     }
  17.     void show() override{
  18.         for(i = a.begin(); i!=a.end();i++){
  19.             cout << (*i) << endl;
  20.         }
  21.     }
  22. };
  23. class insurance : public organization{
  24. protected:
  25.     void add() override{
  26.         a.push_back("Страховая компания");
  27.     }
  28.     void show() override{
  29.      for(i = a.begin(); i!=a.end();i++){
  30.             cout << (*i) << endl;
  31.         }
  32.     }
  33. };
  34. class vessel : public organization{
  35. protected:
  36.     void add() override{
  37.         a.push_back("Судостроительная компания");
  38.     }
  39.     void show() override{
  40.         for(i = a.begin(); i!=a.end();i++){
  41.             cout << (*i) << endl;
  42.         }
  43.     }
  44. };
  45. class org1{
  46. public:
  47.     void show(organization *p){
  48.         p->show();
  49.     }
  50.     void add(organization *ad){
  51.         ad->add();
  52.     }
  53. };
  54. int main() {
  55.     plant e;
  56.     insurance w;
  57.     vessel en;
  58.     org1 per;
  59.     cout << "Список организаций: " << endl;
  60.     per.add(&e);
  61.     per.show(&e);
  62.     per.add(&w);
  63.     per.show(&w);
  64.     per.add(&en);
  65.     per.show(&en);
  66.     return 0;
  67. }
  68.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement