-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathInheritance_Academic_Extracurricular_Result.cpp
64 lines (64 loc) · 1.37 KB
/
Inheritance_Academic_Extracurricular_Result.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
#include<iostream>
using namespace std;
class Academic
{
int roll,m1,m2,m3;
string name;
public:
void getinfo()
{
cout<<"Enter the name : ";
getline(cin,name);
cout<<"Enter the roll no. : ";
cin>>roll;
cout<<"Enter marks in 3 subjects : ";
cin>>m1>>m2>>m3;
}
void showinfo()
{
cout<<"Name : "<<name<<endl;
cout<<"Roll No. : "<<roll<<endl;
cout<<"Marks : "<<m1<<'\t'<<m2<<'\t'<<m3<<endl;
}
int marks()
{
return (m1+m2+m3);
}
};
class Extra
{
protected:
int spm,gpm;
public:
void getmarks()
{
cout<<"Enter the sports marks : ";
cin>>spm;
cout<<"Enter the gp marks : ";
cin>>gpm;
}
};
class Result : private Academic , protected Extra
{
int total;
public:
void gettotal()
{
getinfo();
getmarks();
total= marks()+spm+gpm;
}
void show()
{
showinfo();
cout<<"Sports and gp marks : "<<spm<<'\t'<<gpm<<endl;
cout<<"Total marks : "<<total;
}
};
int main()
{
Result obj;
obj.gettotal();
obj.show();
return 0;
}