-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathquestion2.cpp
More file actions
59 lines (54 loc) · 982 Bytes
/
Copy pathquestion2.cpp
File metadata and controls
59 lines (54 loc) · 982 Bytes
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
/*Write a C++ program to overload unary operators that is increment and decrement.*/
#include<iostream>
using namespace std;
class student
{
private:
int age;
int rank;
public:
int getage()
{
return age;
}
int getrank()
{
return rank;
}
student()
{
}
student(int a,int b)
{
age=a;
rank=b;
}
void display()
{
cout<<"stdudent age "<<age<<" "<<"stdudent rank "<<" "<<rank;
}
student operator++(int post)
{
student temp;
temp.age= age++;
temp.rank= rank++;
return temp;
}
student operator++()
{
student temp;
temp.age= ++age;
temp.rank= ++rank;
return temp;
}
};
int main()
{
student s1(12,24);
s1.display();
cout<<endl;
(++s1).display();
cout<<endl;
(s1++).display();
cout<<endl;
}