View difference between Paste ID: BmAXn2Xq and xfnzA2xh
SHOW: | | - or go back to the newest paste.
1
#include <iostream>
2-
#include <string>
2+
3-
#include <map>
3+
4
5
class Human
6
{
7-
class Student {
7+
8
protected:
9
10
    string surname;
11-
    string m_name;
11+
    string name;
12-
    int m_id;
12+
    string midname;
13
    int age;
14
15
public:
16-
    const string &getName() const {
16+
17-
        return m_name;
17+
    Human()
18
    {
19
        surname = "Ivanov";
20-
    void setName(const string &name) {
20+
        name = "Ivan";
21-
        Student::m_name = name;
21+
        midname = "Ivanovich";
22
        age = 18;
23
    }
24-
    int getId() const {
24+
25-
        return m_id;
25+
    Human(const string &surname, const string &name, const string &midname, int age)
26
    : surname(surname), name(name), midname(midname), age(age) {}
27
28-
    void setId(int id) {
28+
    virtual void print() = 0;
29-
        Student::m_id = id;
29+
30
    ~Human(){}
31
32
};
33
34-
class HeadMan : public Student
34+
class Student : public Human
35
{
36
37
private:
38
39-
    map <string, Student> m_listOfStudents; // список студентов с номерами телефонов
39+
    bool on_lesson;
40-
    map <bool, Student> m_listOfMissing; // список посещеаемости на одну пару
40+
41
public:
42
43
    Student() : Human()
44-
    const map<string, Student> &getListOfStudents() const {
44+
    {
45-
        return m_listOfStudents;
45+
        on_lesson = false;
46
    }
47
48-
    void setListOfStudents(const map<string, Student> &listOfStudents) {
48+
    Student(const string &surname, const string &name, const string &midname, int age, bool on_lesson)
49-
        HeadMan::m_listOfStudents = listOfStudents;
49+
            : Human(surname, name, midname, age), on_lesson(on_lesson) {}
50
51
    void print() override {
52-
    const map<bool, Student> &getListOfMissing() const {
52+
        cout << "Name: " << name << endl
53-
        return m_listOfMissing;
53+
             << "Surmane: " << surname << endl
54
             << "Midname: " << midname << endl
55
             << "Age: " << age << endl
56-
    void setListOfMissing(const map<bool, Student> &listOfMissing) {
56+
             << "Is he/she on lesson: " << boolalpha << on_lesson << endl;
57-
        HeadMan::m_listOfMissing = listOfMissing;
57+
58
59
    ~Student(){}
60
61
};
62
63-
    std::cout << "Hello, World!" << std::endl;
63+
class Boss : public Human
64
{
65
66
private:
67
68
    int number_of_workers;
69
70
public:
71
72
    Boss() : Human()
73
    {
74
        number_of_workers = 0;
75
    }
76
77
    Boss(const string &surname, const string &name, const string &midname, int age, int number_of_workers)
78
            : Human(surname, name, midname, age), number_of_workers(number_of_workers) {}
79
80
    void print() override {
81
        cout << "Name: " << name << endl
82
             << "Surmane: " << surname << endl
83
             << "Midname: " << midname << endl
84
             << "Age: " << age << endl
85
             << "Number of workers: " << number_of_workers << endl;
86
    }
87
88
    ~Boss(){}
89
90
};
91
92
int main() {
93
94
    Student s;
95
    Boss b;
96
97
    s.print();
98
    cout << endl;
99
    b.print();
100
101
    return 0;
102
}