Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <clocale>
- #include <string>
- using namespace std;
- class Human {
- public:
- string name;
- int age;
- int id;
- char gender;
- Human(string name, int age, int id, char gender) {
- this->name = name;
- this->age = age;
- this->id = id;
- this->gender = gender;
- }
- virtual void print();
- virtual ~Human();
- };
- Human::~Human() {
- cout << "destr" << endl;
- }
- void Human::print() {
- cout << "Имя: " << name << ", " << age << " лет" << endl;
- cout << "Номер паспорта: " << id << endl;
- cout << "Пол: " << gender << endl;
- }
- class Student: public Human {
- public:
- int course;
- string university;
- string faculty;
- Student(string name, int age, int id, char gender, int course, string university, string faculty):
- Human(name, age, id, gender) {
- this->course = course;
- this->university = university;
- this->faculty = faculty;
- }
- virtual void print() {
- this->Human::print();
- cout << "Университет: " << university << endl;
- cout << "Факультет: " << faculty << endl;
- }
- virtual ~Student() {
- cout << "Объект студента разрушен" << endl;
- }
- };
- class Father: public Human {
- public:
- Human* wife;
- int children_count;
- Human** children;
- Father(string name, int age, int id, char gender, Human* wife, int children_count, Human** children):
- Human(name, age, id, gender) {
- this->wife = wife;
- this->children_count = children_count;
- this->children = children;
- }
- virtual void print() {
- this->Human::print();
- cout << "Дети: " << children_count << endl;
- }
- void add_child(Human& child) {
- }
- void delete_child(Human& child) {
- }
- virtual ~Father() {
- cout << "Объект отца разрушен" << endl;
- }
- };
- class FatherStudent: public Father, public Student {
- public:
- FatherStudent(string name, int age, int id, char gender,
- int course, string university, string faculty,
- Human* wife, int children_count, Human** children):
- Student(name, age, id, gender, course, university, faculty),
- Father(name, age, id, gender, wife, children_count, children) {
- this->course = course;
- this->university = university;
- this->faculty = faculty;
- this->wife = wife;
- this->children_count = children_count;
- this->children = children;
- }
- virtual void print() {
- }
- virtual ~FatherStudent() {
- cout << "Объект отца-студента разрушен" << endl;
- }
- };
- int main() {
- setlocale(0, "");
- Human* wife = new Human("Жена", 18, 160961, 'ж', 1, "СВФУ", "ИМИ");
- FatherStudent* vlad = new Student("Влад", 19, 160962, 'м', 2, "СВФУ", "ИМИ");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement