Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<stdlib.h>
- #include<stdio.h>
- #include<string>
- #include<vector>
- #define _CRT_SECURE_NO_WARNINGS
- using namespace std;
- class Person
- {
- protected:
- char date_of_birth[12]; //дата рождения
- char pol[5]; //пол
- Person * next; //указатель на следующего в списке
- public:
- char fio[100]; //ФИО
- void SetPersonInfo(char *name, char *date, char *Pol)
- {
- Person *p = new Person;
- strcpy_s(p->fio, name);
- strcpy_s(p->date_of_birth, date);
- strcpy_s(p->pol, Pol);
- p->PersonInfo();
- p->next = NULL;
- p = p->next;
- }
- virtual void PersonInfo()
- {
- cout << fio << " ";
- cout << date_of_birth << " ";
- cout << pol << " ";
- }
- };
- class Employee : public Person
- {
- protected:
- Person *per;
- char info[100];
- public:
- void SetEmployeeInfo(char *inform)
- {
- Employee *e = new Employee;
- strcpy_s(e->info, inform);
- e->PersonInfo();
- }
- virtual void PersonInfo()
- {
- /*cout << this->fio << " ";
- cout << this->date_of_birth << " ";
- cout << this->pol << " ";*/
- cout << this->info << endl;
- }
- };
- class Manager : public Employee
- {
- protected:
- char departament[100];
- Person *employers = NULL;
- public:
- void SetManagerInfo(char *depo)
- {
- Manager *m = new Manager;
- strcpy_s(m->departament, depo);
- m->PersonInfo();
- }
- void AddEmployee(Person *p)
- {
- p = employers;
- }
- virtual void PersonInfo()
- {
- cout << this->departament << endl;
- }
- };
- class Chief : public Manager
- {
- protected:
- char firm[100];
- vector<string> managers;
- //char managers[10][100];
- public:
- void SetChiefInfo(char* firm_name)
- {
- Chief *c = new Chief;
- strcpy_s(c->firm, firm_name);
- c->PersonInfo();
- }
- void AddManager(Manager *m)
- {
- managers.push_back(m->fio);
- }
- void GetManagers(Chief *&c)
- {
- int i = 0;
- cout << c->fio << " " << c->firm << endl;
- while (i < managers.size())
- {
- cout << managers[i] << endl;
- i++;
- }
- managers.clear();
- }
- virtual void PersonInfo()
- {
- cout << this->firm << endl;
- }
- };
- int main()
- {
- Person *p1 = NULL;
- Employee *e1 = NULL;
- Manager *m1 = NULL;
- Chief *c1 = NULL;
- c1->SetPersonInfo("Ostap Bender", "14.08.1985", "male");
- c1->SetChiefInfo("Horns & hooves");
- e1->SetPersonInfo("Petya", "12.12.1992", "male");
- e1->SetEmployeeInfo("Ingener");
- m1->SetPersonInfo("Shyra","01.01.1991","male");
- m1->SetManagerInfo("Departament of Testing");
- //m1->AddEmployee(e1);
- c1->AddManager(m1);
- c1->GetManagers(c1);
- system("pause");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement