Advertisement
Guest User

C++ сиспрога, недоделка

a guest
Dec 13th, 2017
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.62 KB | None | 0 0
  1. #include <iostream>
  2. #include <clocale>
  3. #include <string>
  4.  
  5. using namespace std;
  6.  
  7. class Human {
  8. public:
  9.     string name;
  10.     int age;
  11.     int id;
  12.     char gender;
  13.     Human(string name, int age, int id, char gender) {
  14.         this->name = name;
  15.         this->age = age;
  16.         this->id = id;
  17.         this->gender = gender;
  18.     }
  19.     virtual void print();
  20.     virtual ~Human();
  21. };
  22. Human::~Human() {
  23.     cout << "destr" << endl;
  24. }
  25. void Human::print() {
  26.     cout << "Имя: " << name << ", " << age << " лет" << endl;
  27.     cout << "Номер паспорта: " << id << endl;
  28.     cout << "Пол: " << gender << endl;
  29. }
  30.  
  31. class Student: public Human {
  32. public:
  33.     int course;
  34.     string university;
  35.     string faculty;
  36.     Student(string name, int age, int id, char gender, int course, string university, string faculty):
  37.     Human(name, age, id, gender) {
  38.         this->course = course;
  39.         this->university = university;
  40.         this->faculty = faculty;
  41.     }
  42.     virtual void print() {
  43.         this->Human::print();
  44.         cout << "Университет: " << university << endl;
  45.         cout << "Факультет: " << faculty << endl;
  46.     }
  47.     virtual ~Student() {
  48.         cout << "Объект студента разрушен" << endl;
  49.     }
  50. };
  51.  
  52. class Father: public Human {
  53. public:
  54.     Human* wife;
  55.     int children_count;
  56.     Human** children;
  57.     Father(string name, int age, int id, char gender, Human* wife, int children_count, Human** children):
  58.     Human(name, age, id, gender) {
  59.         this->wife = wife;
  60.         this->children_count = children_count;
  61.         this->children = children;
  62.     }
  63.     virtual void print() {
  64.         this->Human::print();
  65.         cout << "Дети: " << children_count << endl;
  66.     }
  67.     void add_child(Human& child) {
  68.     }
  69.     void delete_child(Human& child) {
  70.     }
  71.     virtual ~Father() {
  72.         cout << "Объект отца разрушен" << endl;
  73.     }
  74. };
  75.  
  76. class FatherStudent: public Father, public Student {
  77. public:
  78.     FatherStudent(string name, int age, int id, char gender,
  79.         int course, string university, string faculty,
  80.         Human* wife, int children_count, Human** children):
  81.     Student(name, age, id, gender, course, university, faculty),
  82.     Father(name, age, id, gender, wife, children_count, children) {
  83.         this->course = course;
  84.         this->university = university;
  85.         this->faculty = faculty;
  86.         this->wife = wife;
  87.         this->children_count = children_count;
  88.         this->children = children;
  89.     }
  90.     virtual void print() {
  91.  
  92.     }
  93.     virtual ~FatherStudent() {
  94.         cout << "Объект отца-студента разрушен" << endl;
  95.     }
  96. };
  97.  
  98. int main() {
  99.     setlocale(0, "");
  100.     Human* wife = new Human("Жена", 18, 160961, 'ж', 1, "СВФУ", "ИМИ");
  101.     FatherStudent* vlad = new Student("Влад", 19, 160962, 'м', 2, "СВФУ", "ИМИ");
  102. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement