填空题
写出程序运行结果:_________#include //using namespace std;class Complex{ public: Complex(double r = 0.0, double i = 0.0) : real(r), imag(i) { } friend Complex operator + (const Complex &c1, const Complex &c2); friend Complex operator - (const Complex &c1, const Complex &c2); friend ostream & operator << (ostream &out, const Complex &c);private: double real; double imag;}; Complex operator + (const Complex &c1, const Complex &c2){ return Complex(c1.real + c2.real, c1.imag + c2.imag);}Complex operator - (const Complex &c1, const Complex &c2) { return Complex(c1.real - c2.real, c1.imag - c2.imag);}ostream & operator << (ostream &out, const Complex &c) { out << "(" << c.real << "," << c.imag <<")"; return out;}int main() { Complex c1(5, 4), c2(2, 10), c3; cout << "c1=" << c1 << endl; cout << "c2=" << c2 << endl; c3 = c1 - c2; cout << "c3=c1-c2=" << c3 << endl; c3 = c1 + c2; cout << "c3=c1+c2=" << c3 << endl; return 0;}
套餐购买该问题答案仅对会员开放,欢迎开通会员 ¥ 19.9
0.64/天
1个月(不限次)
¥ 19.9
1000次
(不限时)
¥ 29.9
0.32/天
3个月(不限次)
¥ 59.9
0.16/天
1年(不限次)
立即支付