Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <list>
- using namespace std;
- class organization{
- public:
- virtual void show() = 0;
- virtual void add() = 0;
- list <string> a;
- list <string> :: iterator i;
- };
- class plant : public organization{
- protected:
- void add() override{
- a.push_back("Завод");
- }
- void show() override{
- for(i = a.begin(); i!=a.end();i++){
- cout << (*i) << endl;
- }
- }
- };
- class insurance : public organization{
- protected:
- void add() override{
- a.push_back("Страховая компания");
- }
- void show() override{
- for(i = a.begin(); i!=a.end();i++){
- cout << (*i) << endl;
- }
- }
- };
- class vessel : public organization{
- 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(organization *p){
- p->show();
- }
- void add(organization *ad){
- ad->add();
- }
- };
- int main() {
- plant e;
- insurance w;
- vessel 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