有如下程序:#includeusing namespace std;class Complex{double re, im;public:Complex(double r, double i):re(r), im(i){}double real() const{return re;}double image() const{return im;}Complex operator +=(Complex a){re += a.re;im += a.im;return *this;}};ostream operator(ostream s,const Complex z){return s'('}int main(){Complex x(1, -2), y(2, 3);cout(x += y)return 0;}执行这个程序的输出结果是A . (1, -2)B . (2, 3)C . (3, 5)D . (3, 1)

有如下程序:

#include

using namespace std;

class Complex

{

double re, im;

public:

Complex(double r, double i):re(r), im(i){}

double real() const{return re;}

double image() const{return im;}

Complex& operator +=(Complex a)

{

re += a.re;

im += a.im;

return *this;

}

};

ostream &operator<<(ostream& s,const Complex& z)

{

return s<<'('<

}

int main()

{

Complex x(1, -2), y(2, 3);

cout<<(x += y)<

return 0;

}

执行这个程序的输出结果是

A . (1, -2)

B . (2, 3)

C . (3, 5)

D . (3, 1)


相关考题:

有以下程序include using namespace std;class Complex{public: Complex(double r=O, 有以下程序 #include<iostream> using namespace std; class Complex { public: Complex(double r=O,double i=0):re(r),im(i){} double real() const {return re;} double imag()const {return im;} Complex operator +(Complex C) const {return Complex (re+c.re,im+c.im);} private: double re,im; }; int main() { Complex a=Complex(1,1)+Complex (5); cout<<a.real()<<'+'<<a.imag()<<'i'<<endl; retum 0; } 程序执行后的输出结果是A.6+6iB.6+1iC.1+6iD.1+1i

有以下程序include using namespacestd;class Complex{public:Complex (doubler=0, d 有以下程序 #include <iostream> using namespace std; class Complex { public: Complex (double r=0, double i =0 :re(r) ,im (i) {} double real() const {return re;} double imag() const { return im;} Complex operator + (Complex c} const {return Complex(re+c.re, im+c.im);} privane: double re,im; }; int main { Complex a =Complex (1,1)+Complex(5); cout<<a.real()<<'+'<<a.imag() << 'i' <<endl return 0; } 程序执行后的输出结果是A.6+6iB.6+1iC.1+6iD.1+1i

有以下程序include using namespace std;class Complex{public:Complex(double r=0,d 有以下程序#include <iostream>using namespace std;class Complex{public: Complex(double r=0,double i=0):re(r),im(i){ double real() const {return re;} double imag() const { return im; } Complex operator+(Complex c) const {return Complex(re+c.re,im+c.im);}private: double re,im;};int main(){ Complex a =Complex(1,1)+ Complex(5); cout<<a.real()<<'+'<<a.imag()<<'i'<<end1; retura 0;}A.6+6iB.6+1iC.1+6iD.1+1i

有如下程序: include using namespace std; class Complex { double 有如下程序: #include<iostream> using namespace std; class Complex { double re,im; public: Complex(double r,double i):re(r),im(i){} double real()const{return re;} double image()const{return im;} Complex operator+=(Complex a) { re+=a.re; im+=a.im; return *this; } }; ostream operator<<(ostream s,const Complex z) { return s<<'('<<z.real()<<','<<z.image()<<')'; } int main() { Complex x(1,2),y(2,3); tout<<(x+=y)<<endl; return 0; } 执行这个程序的输出结果是( )。A.(1,-2)B.(2,3)C.(3,5)D.(3,1)

有以下程序,输出结果()。includeusing namespace std;class Complex{public:Complex(d 有以下程序,输出结果( )。 #include<iostream> using namespace std; class Complex { public: Complex(double r=0,double i=0):re(r),im(i){} double real()const{return re;} double imagoconst{return im;} Complex operator+(Complex C) const {return Complex(re+c.re,im+c.im);} private: double re,im; }; int main() { Complex a=Complex(1,1)+Complex(5); cout<<a.real()<<'+'<<a.imag()<<'i'<<end1; return 0; }A.6+iB.2i+5C.6+1iD.1i+5

有以下程序; #includeiostream usingnamespacestd; classComplex { public: Complex(doubler=0,doublei=O):re(r),im(i){} doublereal()const{returnre;} doubleimag()const{returnim;} Complexoperator+(Complexc)const {returnComplex(re+C.re,im+C.im);} private: doublere,im; }; intmain() { Complexa=Complex(1,1)+Complex(5); couta.real()+a.imag()iendl; return0; } 程序执行后的输出结果是( )。A.6+6iB.6+1iC.1+6iD.1+1i

有下列程序:includeusing namespace std;class Complex{double re,im;public:Complex 有下列程序: #include<iostream> using namespace std; class Complex { double re,im; public: Complex(double r,double i):re(r),im(i){} double real()const{retum re;} double image()const{return im;} Complex operator+=(Complex A) { rA.(1,-2)B.(2,3)C.(3,5)D.(3,1)

有以下程序: include using namespace std; class Complex{public: Complex(double 有以下程序: #include <iostream> using namespace std; class Complex { public: Complex(double r=0,double i=0):re(r),im(i){ double zeal() const {return re;} double imag() const {return im;} Complex operator+(Complex c) const { return Complex(re+c.re,im+c.im);} private: double re,im; }; int main() Complex a=Complex(1,1)+Complex(5); cout<<a.real()<<'+'<<a.imag()<<'i'<<end 1; return 0; }程序执行后的输出结果是______。A.6+6iB.6+1iC.1+6iD.1+1i

有如下程序: include using namespace std; class Complex { dou 有如下程序: #include<iostream> using namespace std; class Complex { double re, im; public: Complex(double r, double i): re(r), im(i) {} double real() const { return re; } double image() const { return im; } Complex operator+= (Complex a) { re += a.re; im += a.im; return *this; } }; ostream operator<<(ostream s, const Complex z) { remm s<<'('<<z.real()<<','<<z.image()<<')'; } int main() { Complex x(1,-2), y(2,3); cout<<(x+=y)<<endl; return 0; } 执行这个程序的输出结果是A.(1,-2)B.(2,3)C.(3,5)D.(3,1)

有以下程序:includeusing namespace std;class Complex{public:Complex(dOuble r=0,d 有以下程序: #include<iostream> using namespace std; class Complex { public: Complex(dOuble r=0,dOuble i=0):re(r),im(i){} doublereal()const{return re;} doubleimag()const{return im;} Complex operator+(Complex c)const {return ComplexA.6+6iB.6+1iC.1+6iD.1+1i