Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- class Human
- {
- protected:
- string surname;
- string name;
- string midname;
- int age;
- public:
- Human()
- {
- surname = "Ivanov";
- name = "Ivan";
- midname = "Ivanovich";
- age = 18;
- }
- Human(const string &surname, const string &name, const string &midname, int age)
- : surname(surname), name(name), midname(midname), age(age) {}
- virtual void print() = 0;
- ~Human(){}
- };
- class Student : public Human
- {
- private:
- bool on_lesson;
- public:
- Student() : Human()
- {
- on_lesson = false;
- }
- Student(const string &surname, const string &name, const string &midname, int age, bool on_lesson)
- : Human(surname, name, midname, age), on_lesson(on_lesson) {}
- void print() override {
- cout << "Name: " << name << endl
- << "Surmane: " << surname << endl
- << "Midname: " << midname << endl
- << "Age: " << age << endl
- << "Is he/she on lesson: " << boolalpha << on_lesson << endl;
- }
- ~Student(){}
- };
- class Boss : public Human
- {
- private:
- int number_of_workers;
- public:
- Boss() : Human()
- {
- number_of_workers = 0;
- }
- Boss(const string &surname, const string &name, const string &midname, int age, int number_of_workers)
- : Human(surname, name, midname, age), number_of_workers(number_of_workers) {}
- void print() override {
- cout << "Name: " << name << endl
- << "Surmane: " << surname << endl
- << "Midname: " << midname << endl
- << "Age: " << age << endl
- << "Number of workers: " << number_of_workers << endl;
- }
- ~Boss(){}
- };
- int main() {
- Student s;
- Boss b;
- s.print();
- cout << endl;
- b.print();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement