#include<iostream>
using namespace std;
#include <string.h>
class Integer {
friend ostream& operator<<(ostream& cout, Integer inter);
public:
Integer() {
m_Num = 0;
}
Integer& operator++() {
m_Num++;
return *this;
}
Integer operator++(int) {
Integer temp = *this;
m_Num++;
return temp;
}
private:
int m_Num;
};
ostream& operator<<(ostream& cout, Integer inter) {
cout << inter.m_Num;
return cout;
}
void test01() {
Integer inter;
cout << ++inter << endl;
}
void test02() {
Integer inter;
cout << inter++ << endl;
cout << inter << endl;
}
int main() {
test02();
system("pause");
return 0;
}代码片
|