声明复数类complx,该类中有两个私有变量real,image分别表示一个复数的实部和虚部,

360U1502161260 |浏览1260次
收藏|2019/07/06 17:14

满意回答

2019/07/06 17:32

很基础的类定义(若是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);}

whoami1978

其他回答(0)
0人关注该问题
+1

 加载中...