-
Notifications
You must be signed in to change notification settings - Fork 0
/
hybrid_inheritance.cpp
120 lines (113 loc) · 2.74 KB
/
hybrid_inheritance.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#include <iostream>
using namespace std;
class unversity
{
char uname[20];
public:
void getdata()
{
cout << "Enter unversity name: ";
cin >> uname;
}
void putdata()
{
// cout << "Unversity name: " << uname << endl;
cout << uname << "\t\t ";
}
};
class college : public unversity
{
char college_name[20];
public:
void getdata()
{
unversity::getdata();
cout << "Enter college name: ";
cin >> college_name;
}
void putdata()
{
unversity::putdata();
// cout<<"College name: "<<college_name<<endl;
cout << college_name << "\t\t";
}
};
class student : public college
{
int marks;
char name[20];
int roll;
public:
void getdata()
{
college::getdata();
cout << "Enter name: ";
cin >> name;
cout << "Enter roll: ";
cin >> roll;
cout << "Enter marks: ";
cin >> marks;
}
void putdata()
{
college::putdata();
cout << name << "\t " << roll << "\t\t " << marks << "\t";
// cout << "Name: " << name << endl;
// cout << "Roll: " << roll << endl;
// cout<<"Marks: "<<marks<<endl;
}
};
class teacher : public college
{
int salary;
char name[20];
char subject[20];
public:
void getdata()
{
college::getdata();
cout << "Enter name: ";
cin >> name;
cout << "Enter teaching subect: ";
cin >> subject;
cout << "Enter salary: ";
cin >> salary;
}
void putdata()
{
college::putdata();
cout << name << "\t " << subject << "\t\t " << salary << "\t";
// cout<<"Name: "<<name<<endl;
// cout<<"Subject: "<<subject<<endl;
// cout<<"Salary: "<<salary<<endl;
}
};
class manager : public student, public teacher
{
public:
void getdata()
{
cout << "Enter Student details:" << endl;
student::getdata();
cout << "\n"
<< "Enter Teacher details:" << endl;
teacher::getdata();
}
void putdata()
{
cout << "Student details:" << endl;
cout << "Unversity\t College\t Name\t Roll No.\t Marks" << endl;
cout << "````````````````````````````````````````````````````````````````" << endl;
student::putdata();
cout <<"\n\nTeacher details:" << endl;
cout << "Unversity\t College\t Name\t Subject\t Salary" << endl;
cout << "````````````````````````````````````````````````````````````````" << endl;
teacher::putdata();
}
};
int main()
{
manager m;
m.getdata();
m.putdata();
}