-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvirtualclass.cpp
More file actions
128 lines (70 loc) · 1.1 KB
/
virtualclass.cpp
File metadata and controls
128 lines (70 loc) · 1.1 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
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
#include<iostream>
using namespace std;
class student
{
protected:
int roll_number;
public:
void get_number(int a)
{
roll_number = a;
}
void put_number(void)
{
cout<<"Roll No: "<< roll_number <<"\n";
}
};
class test : virtual public student
{
protected:
float part1, part2;
public:
void get_marks(float x, float y)
{
part1 = x;
part2 = y;
}
void put_marks(void)
{
cout<<"Marks obtained: " <<"\n";
cout<<"Part 1 = "<<part1 <<"\n";
cout<<"part 2 = "<<part2 <<"\n";
}
};
class sports : public virtual student
{
protected:
float score;
public:
void get_score(float s)
{
score = s;
}
void put_score(void)
{
cout<<"Sports wt:" << score << "\n\n";
}
};
class result : public test, public sports
{
float total;
public:
void display(void);
};
void result :: display(void)
{
total = part1 + part2;
put_number();
put_marks();
put_score();
cout<< "Total Score: " <<total<<"\n";
}
int main()
{
result student1;
student1.get_number(678);
student1.get_marks(30.5, 25.5);
student1.get_score(7.0);
student1.display();
return 0;
}