-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathq52.cpp
35 lines (33 loc) · 866 Bytes
/
q52.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
/*
* WAP to demonstrate the overloading of unary increment operator.
*/
#include <iostream>
using namespace std;
class Box {
int length, breadth, height;
public:
Box() {
length = breadth = height = 0;
}
Box(int length, int breadth, int height) :
length(length), breadth(breadth), height(height) { }
void operator ++() {
length += 1;
breadth += 1;
height += 1;
}
void display() {
cout << "Length = " << length << '\n';
cout << "Breadth = " << breadth << '\n';
cout << "Height = " << height << '\n';
}
};
int main() {
Box b(10, 10, 10);
cout << "Box dimensions before increment: \n";
b.display();
++b;
cout << "\nBox dimensions after increment: \n";
b.display();
return 0;
}