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 GetName() const {
- return name_;
- }
- int GetAge() const {
- return age_;
- }
- string GetGender() const {
- return gender_;
- }
- virtual void Print() {
- cout << "Я служащий" << endl;
- }
- void SetName(string name) {
- name_ = name;
- }
- void SetAge(int age) {
- age_ = age;
- }
- void SetGender(string gender) {
- gender_ = gender;
- }
- protected:
- 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