Untitled

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

class Human {
	private:
		string name;
		string surname;
		int age;
	public:
		Human(): name("Vasiliy"), surname("Pupkin"), age(18) 
		{}
		Human(string name, string surname, int age) : name(name), surname(surname), age(age) 
		{}
		void get_data() {
			cout << "Name: " << name << endl;
			cout << "Surname: " << surname << endl;
			cout << "Age: " << age << endl;
		}
};

class Pupil {
	private:
		Human someone;
		int grade;
		int school;
		float average_mark;
	public:
		Pupil() : grade(9), school(1550), average_mark(4) 
		{}
		Pupil(Human personal_data, int grade, int school, float average_mark) : someone(personal_data), grade(grade), school(school), average_mark(average_mark)
		{}
		void get_data() {
			someone.get_data();
			cout << "Grade: " << grade << endl;
			cout << "School: " << school << endl;
			cout << "Average mark: " << average_mark << endl;
		}
};

class Extended_pupil {
	private:
		Pupil pupil;
		string favourite_color;
	public:
		Extended_pupil(): favourite_color("red")
		{}
		Extended_pupil(Pupil personal_data, string favourite_color): pupil(personal_data), favourite_color(favourite_color)
		{}
		void get_data() {
			pupil.get_data();
			cout << "Favourite_color: " << favourite_color << endl;
		}
};

int main() {
	Extended_pupil vasya;
	vasya.get_data();
}