-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlec45.cpp
90 lines (81 loc) · 1.54 KB
/
lec45.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
#include <iostream>
using namespace std;
class Student
{
public:
int rollNo;
void setData()
{
cout << "Roll No of the student is " << endl;
cin >> rollNo;
}
void getData()
{
cout << "Roll No of the student is " << rollNo << endl;
}
};
class Test : virtual public Student
{
protected:
int phy;
int math;
public:
void setMarks(int p, int m)
{
phy = p;
math = m;
}
void displayMarks()
{
cout << "Marks in Physics" << phy << endl;
cout << "Marks in math " << math << endl;
}
void TotalMarks()
{
int sum;
sum = phy + math;
cout << "Sum of the Marks is:" << sum << endl;
}
};
class Sport : virtual public Student
{
public:
int cric, footbal;
void setScore(int c, int f)
{
cric = c;
footbal = f;
cout << "Score in cric:" << cric << endl;
cout << "Score in football: " << footbal << endl;
}
void displayScore()
{
int total;
total = cric + footbal;
cout << "Total Score is: "
<< total << endl;
}
};
class Result : public Test, public Sport
{
public:
int Final;
void FinalResult()
{
Final = math + phy + cric + footbal;
cout << "Final Result of the Student is:\n " << Final << endl;
}
};
int main()
{
Result R;
R.setData();
R.setMarks(70, 72);
R.getData();
R.displayMarks();
R.TotalMarks();
R.setScore(5, 4);
R.displayScore();
R.FinalResult();
return 0;
}