Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- class Human
- {
- private:
- int parentField;
- protected:
- int height{42};
- public:
- std::string name;
- int age;
- void print() { std::cout << name << ' ' << age << ' ' << height << '\n'; };
- };
- class Teacher : protected Human
- {
- public:
- std::string universityName;
- void printTeacher() { print(); std::cout << universityName << '\n'; }
- //void setHeight(int heightP) { height = heightP; };
- // int getHeight() { return height; };
- };
- class Student : public Human
- {
- public:
- std::string universityName;
- float avgGrade;
- };
- class Employee : public Human
- {
- public:
- std::string companyName;
- double salary;
- };
- int main()
- {
- Teacher me;
- /* me.name = "Alexander";
- me.age = 38;*/
- me.universityName = "STEP";
- me.printTeacher();
- //me.print();
- //me.setHeight(182);
- //std::cout << me.getHeight() << '\n';
- Student student1;
- student1.name = "Bill";
- student1.age = 44;
- student1.universityName = "STEP";
- student1.avgGrade = 9.7;
- student1.print();
- }
Add Comment
Please, Sign In to add comment