-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathStudent_marks_result_inheritance.cpp
73 lines (73 loc) · 1.5 KB
/
Student_marks_result_inheritance.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
#include<iostream>
using namespace std;
class Student
{
int roll;
string name;
public:
void getinfo()
{
cout<<"Enter the name of the student : ";
getline(cin,name);
cout<<"Enter the roll no. : ";
cin>>roll;
}
void showinfo()
{
cout<<"Name is : "<<name<<endl;
cout<<"Roll No. is :"<<roll<<endl;
}
};
class Marks : private Student
{
protected:
int m1,m2,m3,m4,m5;
public:
void getmarks()
{
cout<<"Enter the marks of five subjects : ";
cin>>m1>>m2>>m3>>m4>>m5;
}
void si()
{
showinfo();
}
void gi()
{
getinfo();
}
};
class Result : protected Marks
{
int sports,total;
public:
void gettotal()
{
cout<<"Enter the sports marks : ";
cin>>sports;
total=m1+m2+m3+m4+m5+sports;
}
void showall()
{
gi();
getmarks();
gettotal();
si();
cout<<"marks are : "<<m1<<"\t"<<m2<<"\t"<<m3<<"\t"<<m4<<"\t"<<m5<<"\t"<<sports<<endl;
cout<<"total marks are : "<<total;
}
/*void gii()
{
gi();
}
void sii()
{
si();
}*/
};
int main()
{
Result obj;
obj.showall();
return 0;
}