Advertisement
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:
- string SetName(string name) {
- name_ = name;
- }
- string GetName() {
- return name_;
- }
- string SetAge(int age) {
- age_ = age;
- }
- int GetAge() {
- return age_;
- }
- string SetGender(string gender) {
- gender_ = gender;
- }
- string GetGender() {
- return gender_;
- }
- virtual void Print() = 0;
- private:
- string name_;
- int age_;
- string gender_;
- };
- class President : public Employer {
- public:
- void Print() {
- cout << "Я президент" << 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
Advertisement