注意:此页面搜索的是所有试题
[分析题,4分] #include <iostream.h>cass complex{ private: double real, image; complex( ) { real =0.0;image=0.0;}complex(double r, double i) { real =r; image=i; }void print(){cout<<real<<’+’<<image<<’i’<<endl;}friend complex operator+(complex col ,complex co2);}; complex operator+(complex col ,complex co2) { complex temp; temp.real=col.real+co2.real; temp.imag=col.imag+co2.imag; return temp;}main(){ complex c1(1.1,2.2), c2(3.3,4.4), sum; c1.print(); sum=c1+c2; sum.print();}

参考答案