-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMultiple_Inheritance.cpp
53 lines (46 loc) · 982 Bytes
/
Multiple_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
#include <bits/stdc++.h>
using namespace std;
// Multiple Inheritance
class Student
{
public:
string name;
int rollno;
// constructor
Student(string name, int rollno)
{
this->name = name;
this->rollno = rollno;
}
};
class Teacher
{
public:
string subject;
double salary;
// constructor
Teacher(string subject, double salary)
{
this->subject = subject;
this->salary = salary;
}
};
class TeachingAssistant : public Student, public Teacher
{
public:
TeachingAssistant(string name, int rollno, string subject, double salary)
: Student(name, rollno), Teacher(subject, salary) {}
void getInfo()
{
cout << "Name : " << name << endl;
cout << "rollno : " << rollno << endl;
cout << "subject : " << subject << endl;
cout << "salary : " << salary << endl;
}
};
int main()
{
TeachingAssistant t1("John", 101, "Mathematics", 50000.0);
t1.getInfo();
return 0;
}