-
Notifications
You must be signed in to change notification settings - Fork 0
/
inheritance lab 1.cpp
86 lines (75 loc) · 1.56 KB
/
inheritance lab 1.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
74
75
76
77
78
79
80
81
82
83
84
85
86
//we inherit base class student in the derived class Level 4 grad student or
//as named here as L4Student
#include<bits/stdc++.h>
using namespace std;
class Student{
int theory;
int sessional;
public:
void setMarks(int t,int s)
{
theory=t;
sessional=s;
}
int getTheory()
{
return theory;
}
int getSessional()
{
return sessional;
}
};
class L4Student: private Student
{
private:
int thesis;
public:
void delegate_setMarks(int b,int c)
{
setMarks(b,c);
}
int delegate_get()
{
return getTheory();
}
int delegate_get2()
{
return getSessional();
}
int total(int a,int b,int c)
{
setMarks(b,c);
thesis=c;
int sum;
sum=int(a+b+c);
return sum;
}
void setThesis(int t)
{
thesis=t;
}
int getThesis()
{
return thesis;
}
};
int main()
{
L4Student obj1;
int a,b,c;
cout<<"Enter thesis marks"<<endl;
cin>>a;
obj1.setThesis(a);
cout<<"Enter sessional marks"<<endl;
cin>>b;
cout<<"Enter theory marks"<<endl;
cin>>c;
obj1.delegate_setMarks(b,c);
obj1.total(a,b,c);
cout<<"Thesis Marks "<<obj1.getThesis()<<endl;
cout<<"Sessional marks "<<obj1.delegate_get2()<<endl;
cout<<"Theory marks "<<obj1.delegate_get()<<endl;
cout<<"Total marks: "<<obj1.total(a,b,c)<<endl;
return 0;
}