Untitled
unknown
plain_text
2 years ago
1.4 kB
2
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; string fav_colour; public: Pupil() : someone(), num_of_school(0), average(0), fav_colour("White") { } Pupil(string name, string surname, int age, int num_of_school, int average,string fav_colour) : someone(name, surname, age), num_of_school(num_of_school), average(average),fav_colour(fav_colour) { } void get_data() { this->someone.get_data(); cout << num_of_school << endl; cout << average << endl; cout << fav_colour << endl; } }; int main() { Human basic; Human Alex("Alex", "Smirnov", 20); Pupil basic_pupil; Pupil pupil_Alex = Pupil("Alex", "Smirnov", 20, 195, 5,"Red"); Alex.get_data(); cout << endl; basic.get_data(); cout << endl; pupil_Alex.get_data(); cout << endl; basic_pupil.get_data(); cout << endl; return(0); }