#include"iostream.h"
class Counter
{
private:
int v;
public:
Counter(){}
Counter(int v)
{
this->v=v;
}
Counter operator ++()
{
v++; 也可写为: ++v;
return *this; return v;
}
Counter operator ++(int)
{
Counter t;
t.v=v++;
return t;
}
void disp()
{
cout<<v<<endl;
}
};
void main()
{
Counter c1(3),c2(3),c;
c=c1++;
cout<<"c=c1++ 后, c=";c.disp();
cout<<endl;
cout<<"c=c1++ 后, c1=";c1.disp();
cout<<endl;
c=++c2;
cout<<"c=++c2 后, c=";c.disp();
cout<<endl;
cout<<"c=++c2 后, c2=";c2.disp();
cout<<endl;