Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <list>
- using namespace std;
- class product{
- public:
- virtual void show() = 0;
- virtual void add() = 0;
- list <string> a;
- list <string> :: iterator i;
- };
- class detail : public product{
- protected:
- void add() override{
- a.push_back("Деталь");
- }
- void show() override{
- for(i = a.begin(); i!=a.end();i++){
- cout << (*i) << endl;
- }
- }
- };
- class mechanizm : public product{
- protected:
- void add() override{
- a.push_back("Механизм");
- }
- void show() override{
- for(i = a.begin(); i!=a.end();i++){
- cout << (*i) << endl;
- }
- }
- };
- class node : public product{
- protected:
- void add() override{
- a.push_back("Узел");
- }
- void show() override{
- for(i = a.begin(); i!=a.end();i++){
- cout << (*i) << endl;
- }
- }
- };
- class org1{
- public:
- void show(product *p){
- p->show();
- }
- void add(product *ad){
- ad->add();
- }
- };
- int main() {
- detail e;
- mechanizm w;
- node en;
- org1 per;
- cout << "Список продуктов: " << endl;
- per.add(&e);
- per.show(&e);
- per.add(&w);
- per.show(&w);
- per.add(&en);
- per.show(&en);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement