Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
1.9 kB
1
Indexable
Never
#include <iostream>
using namespace std;

class Human {
private:
    string name;
    string surname;
    int age;

public:
    Human() :name("Oleg"), surname("Sidorov"), age(0) { }

    Human(string name, string surname, int age) : name(name), surname(surname), age(age) { }

    void get_data() {
        cout << this->name << endl << this->surname << endl << this->age << endl;
    }
};


class Pupil {
private:
    Human someone;
    int num_of_school;
    int average;

public:
    Pupil() : someone(), num_of_school(0), average(0) { }

    Pupil(string name, string surname, int age, int num_of_school, int average) :
        someone(name, surname, age), num_of_school(num_of_school), average(average) { }

    void get_data() {
        this->someone.get_data();
        cout << num_of_school << endl;
        cout << average << endl;
    }
};

class Favor {
private:
    Pupil someone;
    string favorite_col;
public:
    Favor() : someone(), favorite_col("black") { };

    Favor(string name, string surname, int age, int num_of_school, int average, string favorite_col) :
        someone(name, surname, age, num_of_school, average), favorite_col(favorite_col) { }

    void get_data() {
        this->someone.get_data();
        cout << favorite_col << endl;
    }
};

int main() {
    Human basic;
    Human Alex("Alex", "Smirnov", 20);

    Pupil basic_pupil;
    Pupil pupil_Alex = Pupil("Alex", "Smirnov", 20, 195, 5);

    Favor basic_pupil_f;
    Favor f_pupil_Alex = Favor("Alex", "Smirnov", 20, 195, 5, "blue");

    Alex.get_data();
    cout << endl;

    basic.get_data();
    cout << endl;

    pupil_Alex.get_data();
    cout << endl;

    basic_pupil.get_data();
    cout << endl;

    f_pupil_Alex.get_data();
    cout << endl;

    basic_pupil_f.get_data();
    cout << endl;
}