Advertisement
evcamels

lr-6-4

Nov 23rd, 2020
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.31 KB | None | 0 0
  1.  
  2. #include <iostream>
  3. #include <list>
  4. using namespace std;
  5. class product{
  6. public:
  7. virtual void show() = 0;
  8. virtual void add() = 0;
  9. list <string> a;
  10. list <string> :: iterator i;
  11. };
  12. class detail : public product{
  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 mechanizm : public product{
  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 node : public product{
  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(product *p){
  48. p->show();
  49. }
  50. void add(product *ad){
  51. ad->add();
  52. }
  53. };
  54. int main() {
  55. detail e;
  56. mechanizm w;
  57. node 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