forked from codebloded/BackToBasics.cpp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmultilevel.cpp
More file actions
69 lines (55 loc) · 1.06 KB
/
multilevel.cpp
File metadata and controls
69 lines (55 loc) · 1.06 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
#include<iostream>
using namespace std;
class Student{
protected:
int rollNumber;
string name;
public:
void setInfo(int, string);
void getInfo(void);
};
void Student :: setInfo(int rn , string _name)
{
rollNumber = rn;
name = _name;
}
void Student::getInfo()
{
cout<<"Roll number: "<<rollNumber<<endl;
cout<<"Name: "<<name<<endl;
}
class Exam : public Student{
protected:
int python ;
int networking;
public:
void setMarks(float , float);
void getMarks(void);
};
void Exam :: setMarks(float x, float y)
{
python = x;
networking = y;
}
void Exam :: getMarks()
{
cout<<"Marks in Python :"<<python;
cout<<"Marks in Networking :"<<networking;
}
class Result : public Exam
{
public:
void result(void)
{
cout<<"Student result is: "<<(python+networking)/2<<"%"<<endl;
}
};
int main()
{
Result rohan;
rohan.setInfo(2,"Rohan");
rohan.getInfo();
rohan.setMarks(98.0,89.0);
rohan.result();
return 0;
}