Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- class human {
- protected:
- double height;
- public:
- virtual void input() = 0;
- virtual void print() = 0;
- };
- class student : human {
- int course;
- public:
- void input() {
- cout << "Enter height: ";
- cin >> height;
- cout << "Enter course: ";
- cin >> course;
- }
- void print() {
- cout << "Height: " << height << endl;
- cout << "Course: " << course << endl;
- }
- };
- class person : human {
- string status;
- public:
- void input() {
- cout << "Enter height: ";
- cin >> height;
- cout << "Enter status: ";
- cin >> status;
- }
- void print() {
- cout << "Height: " << height << endl;
- cout << "Status: " << status<< endl;
- }
- };
- class teacher : human {
- string lesson;
- public:
- void input() {
- cout << "Enter height: ";
- cin >> height;
- cout << "Enter lesson: ";
- cin >> lesson;
- }
- void print() {
- cout << "Height: " << height << endl;
- cout << "Lesson: " << lesson << endl;
- }
- };
- class head_department : human {
- string department;
- public:
- void input() {
- cout << "Enter height: ";
- cin >> height;
- cout << "Enter department: ";
- cin >> department;
- }
- void print() {
- cout << "Height: " << height << endl;
- cout << "Department: " << department << endl;
- }
- };
- int main() {
- student s;
- s.input();
- cout << endl;
- s.print();
- cout << endl;
- person p;
- p.input();
- cout << endl;
- p.print();
- cout << endl;
- teacher t;
- t.input();
- cout << endl;
- t.print();
- cout << endl;
- head_department h;
- h.input();
- cout << endl;
- h.print();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement