Код: Выделить всё
#include
#include
class Person {
protected:
std::string name;
int age;
public:
Person(std::string name, int age) {
this->name = name;
this->age = age;
}
std::string getName() {
return this->name;
}
int getAge() {
return this->age;
}
void celebrateBirthday() {
this->age += 1;
}
};
class Employee : public Person {
private:
int income;
public:
Employee(std::string name, int age, int income) {
this->name = name;
this->age = age;
this->income = income;
}
int getIncome() {
return this->income;
}
};
int main() {
}
Подробнее здесь: https://stackoverflow.com/questions/794 ... -for-class