-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtut39.cpp
More file actions
55 lines (47 loc) · 956 Bytes
/
tut39.cpp
File metadata and controls
55 lines (47 loc) · 956 Bytes
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
#include <iostream>
using namespace std;
class student{
int roll_number;
public:
void set_roll(int);
void get_roll(void);
};
void student :: set_roll(int r){
roll_number = r ;
}
void student :: get_roll(){
cout<< roll_number;
}
class exam : public student {
protected :
float maths;
float physics ;
public :
void setmarks(float ,float);
void getmarks(void);
};
void exam:: setmarks(float m1, float p1){
maths = m1 ;
physics = p1 ;
}
void exam :: getmarks(){
cout<<"The marks of the maths are: "<<maths<<endl;
cout<<"The marks of the physics are: "<<physics<<endl;
}
class result : public exam{
float percentage ;
public:
void getresult(){
get_roll();
getmarks();
cout<<"The result is "<<(maths+physics)/2<<endl;
}
};
int main()
{
result yash;
yash.set_roll(076);
yash.setmarks(88.9,77.7);
yash.getresult();
return 0;
}