Untitled

 avatar
unknown
plain_text
2 years ago
3.1 kB
5
Indexable
#include <iostream>
#include <string>
using namespace std;

class Human {
public:
    // Конструктор класса
    Human(string last_name, string first_name, string patronymic, string gender, int birth_year, string address) {
        this->last_name = last_name;
        this->first_name = first_name;
        this->patronymic = patronymic;
        this->gender = gender;
        this->birth_year = birth_year;
        this->address = address;
    }

    // Методы для вывода и задания значений полей
    void displayInfo() {
        cout << "Фамилия: " << last_name << endl;
        cout << "Имя: " << first_name << endl;
        cout << "Отчество: " << patronymic << endl;
        cout << "Пол: " << gender << endl;
        cout << "Год рождения: " << birth_year << endl;
        cout << "Прописка: " << address << endl;
    }

    void setLastName(string last_name) {
        this->last_name = last_name;
    }

    void setFirstName(string first_name) {
        this->first_name = first_name;
    }

    void setPatronymic(string patronymic) {
        this->patronymic = patronymic;
    }

    void setGender(string gender) {
        this->gender = gender;
    }

    void setBirthYear(int birth_year) {
        this->birth_year = birth_year;
    }

    void setAddress(string address) {
        this->address = address;
    }

 class Student : public Human {
 private:
        Student(int korpus, string faculty, int group) {
 
            this->korpus = korpus;
            this->faculty = faculty;
            this->group = group;
        }

 public:
   

        void Print() {
            cout << "Корпус: " << korpus << endl;
            cout << "факультет: " << faculty << endl;
            cout << "Группа: " << group << endl;

        }
        void setKorpus(int korpus) {
            this->korpus = korpus;
        }

        void setFaculty(string faculty) {
            this->faculty = faculty;
        }

        void setGroup(int group) {
            this->group = group;
        }



private:
    string last_name;
    string first_name;
    string patronymic;
    string gender;
    int birth_year;
    string address;
    int korpus;
    string faculty;
    int group;
};

int main() {
    setlocale(LC_ALL, "rus");
    // Создание объекта класса Human
    Human person("Иванов", "Иван", "Иванович", "Мужской", 1990, "Москва");

    // Вывод информации о человеке
    person.displayInfo();

    // Изменение значения поля "Фамилия"
    person.setLastName("Петров");

    // Вывод обновленной информации о человеке
    person.displayInfo();



    // Создание объекта класса Student
    Student person(9, "ОИБ", 932);

    // Вывод информации о студенте
    person.Print();



    return 0;
}
Editor is loading...
Leave a Comment