-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsrc04151.cpp
More file actions
51 lines (41 loc) · 747 Bytes
/
src04151.cpp
File metadata and controls
51 lines (41 loc) · 747 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
#include "stdafx.h"
#include <iostream>
using namespace std;
class CInt {
public:
CInt(int param) { this->value = param; }
CInt& operator=(const CInt& param) {
this->value = param.value;
return *this;
}
CInt&& operator+(int param) {
return CInt(this->value + param);
}
CInt&& operator+(CInt& param) {
return CInt(this->value + param.value);
}
bool operator==(const CInt& param) {
if (param.value == this->value)
{
return 1;
}
return 0;
}
int operator++(int) {
return ++this->value;
}
int operator++() {
int temp = this->value++;
return temp;
}
int value = 0;
};
int main() {
CInt i1 = 1;
CInt i2 = 1;
if (i1 == i2) {
cout << "same" << endl;
}
cout << i1++ << endl;
cout << ++i2 << endl;
}