-
Notifications
You must be signed in to change notification settings - Fork 1
/
code-13.cpp
58 lines (58 loc) · 1.07 KB
/
code-13.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
// Program to show the virtual base class
#include<iostream>
using namespace std;
class Student{
protected:
int r_no;
public:
void get_n(int a){
r_no=a;
}
void put_n(void){
cout<<"Roll No. : "<<r_no<<endl;
}
};
class Test:virtual public Student{
protected:
int part1,part2;
public:
void get_m(int x,int y){
part1=x;part2=y;
}
void put_m(void){
cout<<"Marks Obtained : "<<endl;
cout<<"Part 1 = "<<part1<<endl;
cout<<"Part 2 = "<<part2<<endl;
}
};
class Sports:public virtual Student{
protected:
int score;
public:
void get_s(int a){
score=a;
}
void put_s(void){
cout<<"Sports wt. : "<<score<<endl;
}
};
class result:public Test,public Sports{
private:int total;
public:
void show(void);
};
void result::show(void){
total=part1+part2+score;
put_n();
put_m();
put_s();
cout<<"Total Score : "<<total<<endl;
}
int main(){
result s1;
s1.get_n(678);
s1.get_m(30,35);
s1.get_s(7);
s1.show();
return 0;
}