.............
#include"iostream.h"
//using namespace std;
class Complex
{
private:
float real;
float imag;
public:
Complex(){}
Complex(float r,float t)
{
this->real=r;
this->imag=t;
}
void print();
friend Complex operator ++(Complex&);
};
void Complex::print()
{
cout<<"c ="<<real<<"+"<<imag<<"i"<<endl;
}
Complex operator ++(Complex&a)
{
return Complex (a.real++,a.imag++);
}
int main()
{
Complex a(1,1),d(0,0);
d=a++;
a.print();
d.print();
d=++a;
d.print();
a.print();
return 0;
}
不知道它是怎么重载的 但是 前置后置可以。。