#include<iostream>
#include<stack>
//#include<ctype.h>
using namespace std;
class Int {
int val;
public:
Int(int my_val):val(my_val) {
}
Int operator++() {
Int tmp(*this);
++(this->val);
return tmp;
}
Int& operator++(int ) {
(this->val)++;
return *this;
}
void Show() {
cout << this->val << endl;
}
};
int main() {
Int c1(888);
c1.Show();
Int c2 = c1++;
c2.Show();
Int c3 = ++c2;
c3.Show();
c2.Show();
}
前置++ 和 后置++的重载
最新推荐文章于 2024-10-16 10:13:45 发布