Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <set>
- #include <string>
- #include <iostream>
- #include <vector>
- using namespace std;
- // Служащий
- class Employer {
- public:
- virtual void Print() = 0;
- protected:
- string name_;
- };
- class President : public Employer {
- public:
- void Print() {
- cout << "Я президент " << name_ << endl;
- }
- };
- class Manager : public Employer {
- public:
- void Print() {
- cout << "Я менеджер" << endl;
- }
- };
- class Worker : public Employer {
- public:
- void Print() {
- cout << "Я рабочий" << endl;
- }
- };
- int main() {
- setlocale(LC_ALL, "ru");
- President pr;
- Manager mn;
- Worker wk;
- vector<Employer*> employers;
- employers.push_back(&pr);
- employers.push_back(&mn);
- employers.push_back(&wk);
- for (auto a : employers) {
- a->Print();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment