很基础的类定义(若是C++的)class complex{ public: friend complex add(complex &x,complex &y); complex() { real = 0.0; imag = 0.0; } complex(float x, float y) { real = x; imag = y; } private: float real; float imag;};complex add(complex &x,complex &y){ return complex( x.real+y.real,x.imag+y.imag);}