-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstudent_overloaded_constructor.cpp
65 lines (64 loc) · 1.14 KB
/
student_overloaded_constructor.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
#include<iostream>
using namespace std;
class StudentMarks
{
private:
int reg_num;
float sub1, sub2, sub3;
float avg, total;
public:
void input()
{
cout<<"\nEnter registration number of the student: ";
cin>>reg_num;
cout<<"\nEnter marks in subject 1(out of 100): ";
cin>>sub1;
cout<<"\nEnter marks in subject 2(out of 100): ";
cin>>sub2;
cout<<"\nEnter marks in subject 3(out of 100): ";
cin>>sub3;
}
void average()
{
total=sub1+sub2+sub3;
avg=total/3.0;
}
void display()
{
cout<<"\n\n*** DISPLAYING DETAILS ***";
cout<<"\n\nREGISTRATION NUMBER: "<<reg_num;
cout<<"\nMARKS IN SUBJECT 1: "<<sub1;
cout<<"\nMARKS IN SUBJECT 2: "<<sub2;
cout<<"\nMARKS IN SUBJECT 3: "<<sub3;
cout<<"\nAVERAGE OF ALL THE THREE SUBJECTS: "<<avg;
}
StudentMarks()
{
reg_num=1;
sub1=100;
sub2=100;
sub3=100;
}
StudentMarks(int reg_num, int sub1, int sub2, int sub3 )
{
reg_num=3;
sub1=90;
sub2=80;
sub3=90;
}
StudentMarks(StudentMarks &s)
{
reg_num=s.reg_num;
sub1=s.sub1;
sub2=s.sub2;
sub3=s.sub3;
}
};
int main()
{
StudentMarks s;
s.input();
s.average();
s.display();
return 0;
}