-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path14.cpp
More file actions
62 lines (53 loc) · 1.16 KB
/
14.cpp
File metadata and controls
62 lines (53 loc) · 1.16 KB
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
#include <iostream>
using namespace std;
class Student {
protected:
string name;
int roll;
string course;
public:
void getDetails() {
cout << "Enter name: ";
cin >> name;
cout << "Enter roll no: ";
cin >> roll;
cout << "Enter course: ";
cin >> course;
}
};
class Test : virtual public Student {
protected:
int mark1, mark2, mark3;
public:
void getMarks() {
cout << "Enter 3 marks: ";
cin >> mark1 >> mark2 >> mark3;
}
};
class GraceMarks : virtual public Student {
protected:
int bonusMark;
public:
void setBonus(int b) {
bonusMark = b;
}
};
class Result : public Test, public GraceMarks {
public:
void displayResult() {
int total = mark1 + mark2 + mark3 + bonusMark;
cout<<"Name: "<<name<<endl;
cout<<"Roll No: "<<roll<<endl;
cout<<"Course: "<<course<<endl;
cout<<"Marks: "<<mark1<<", "<<mark2<<", "<<mark3<<endl;
cout<<"Bonus Marks: "<<bonusMark<<endl;
cout<<"Total Marks: "<<total<<endl;
}
};
int main() {
Result r;
r.getDetails();
r.getMarks();
r.setBonus(5);
r.displayResult();
}