Advertisement
Guest User

пщмтщлщв

a guest
Dec 6th, 2016
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.52 KB | None | 0 0
  1. #include<iostream>
  2. #include<stdlib.h>
  3. #include<stdio.h>
  4. #include<string>
  5. #include<vector>
  6. #define _CRT_SECURE_NO_WARNINGS
  7.  
  8. using namespace std;
  9.  
  10. class Person
  11. {
  12. protected:
  13.  
  14. char date_of_birth[12]; //дата рождения
  15. char pol[5]; //пол
  16. Person * next; //указатель на следующего в списке
  17. public:
  18. char fio[100]; //ФИО
  19. void SetPersonInfo(char *name, char *date, char *Pol)
  20. {
  21. Person *p = new Person;
  22. strcpy_s(p->fio, name);
  23. strcpy_s(p->date_of_birth, date);
  24. strcpy_s(p->pol, Pol);
  25. p->PersonInfo();
  26. p->next = NULL;
  27. p = p->next;
  28. }
  29. virtual void PersonInfo()
  30. {
  31. cout << fio << " ";
  32. cout << date_of_birth << " ";
  33. cout << pol << " ";
  34. }
  35. };
  36.  
  37. class Employee : public Person
  38. {
  39. protected:
  40. Person *per;
  41. char info[100];
  42. public:
  43. void SetEmployeeInfo(char *inform)
  44. {
  45.  
  46. Employee *e = new Employee;
  47. strcpy_s(e->info, inform);
  48. e->PersonInfo();
  49. }
  50. virtual void PersonInfo()
  51. {
  52. /*cout << this->fio << " ";
  53. cout << this->date_of_birth << " ";
  54. cout << this->pol << " ";*/
  55. cout << this->info << endl;
  56. }
  57. };
  58.  
  59. class Manager : public Employee
  60. {
  61. protected:
  62. char departament[100];
  63. Person *employers = NULL;
  64. public:
  65. void SetManagerInfo(char *depo)
  66. {
  67. Manager *m = new Manager;
  68. strcpy_s(m->departament, depo);
  69. m->PersonInfo();
  70. }
  71. void AddEmployee(Person *p)
  72. {
  73. p = employers;
  74. }
  75. virtual void PersonInfo()
  76. {
  77. cout << this->departament << endl;
  78. }
  79. };
  80.  
  81. class Chief : public Manager
  82. {
  83. protected:
  84. char firm[100];
  85. vector<string> managers;
  86. //char managers[10][100];
  87. public:
  88. void SetChiefInfo(char* firm_name)
  89. {
  90. Chief *c = new Chief;
  91. strcpy_s(c->firm, firm_name);
  92. c->PersonInfo();
  93. }
  94. void AddManager(Manager *m)
  95. {
  96. managers.push_back(m->fio);
  97. }
  98. void GetManagers(Chief *&c)
  99. {
  100. int i = 0;
  101. cout << c->fio << " " << c->firm << endl;
  102. while (i < managers.size())
  103. {
  104. cout << managers[i] << endl;
  105. i++;
  106. }
  107. managers.clear();
  108. }
  109. virtual void PersonInfo()
  110. {
  111. cout << this->firm << endl;
  112. }
  113. };
  114.  
  115. int main()
  116. {
  117. Person *p1 = NULL;
  118. Employee *e1 = NULL;
  119. Manager *m1 = NULL;
  120. Chief *c1 = NULL;
  121. c1->SetPersonInfo("Ostap Bender", "14.08.1985", "male");
  122. c1->SetChiefInfo("Horns & hooves");
  123. e1->SetPersonInfo("Petya", "12.12.1992", "male");
  124. e1->SetEmployeeInfo("Ingener");
  125. m1->SetPersonInfo("Shyra","01.01.1991","male");
  126. m1->SetManagerInfo("Departament of Testing");
  127. //m1->AddEmployee(e1);
  128. c1->AddManager(m1);
  129. c1->GetManagers(c1);
  130. system("pause");
  131. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement