当前位置: 答题翼 > 问答 > 计算机类考试 > 正文
目录: 标题| 题干| 答案| 搜索| 相关
问题

阅读以下说明和C++代码(代码13-1) 将应填入(n)处的字句写在对应栏内。 【说明】软件设计师东方飞龙


阅读以下说明和C++代码(代码13-1),将应填入(n)处的字句写在对应栏内。

【说明】

软件设计师东方飞龙利用UML设计了一个迷你小型复数类,其类图如图13-11所示。

【代码13-l】

/*___________________________________*/

/********* 文件 MiniComplex. h*********/

/*___________________________________*/

include<iostream>

using namespace std;

class MiniComplex

{(1):

//重载流插入和提取运算符

(2) ostream & operator <<(ostream & osObject, const MiniComplex & complex)

{ osObject <<"("<<complex. realPart<<"+"<<complex. imagPart <<"I"<<")";

return osObject;

}

friend (3) operator >>(istream & isObject, MiniComplex & complex)

{ char ch;

isObject >>complex. realPart >>ch>>complex. imagPart >>ch;

return isObject;

}

MiniComplex(double real=0, double imag=0); //构造函数

MiniComplex operator+(const MiniComplex & otherComplex)const! //重载运算符+

MiniComplex operator--(const MiniComplex & otherComplex)const! //重载运算符-

MiniComplex operator*(const MiniComplex& othmComplex)const; //重载运算符*

MiniComplex operator/(const MiniComplex & otherComplex)const; //重载运算符/

bool perator==(const MiniComplex &otherComplex)const; //重载运算符==

private:

double realPart; //存储实部变量

double imagPart; //存储虚部变量

};

/*_______________________________________________________*/

/* * * * * * * * *文件 MiniComplex. cpp* * * * * * * * * */

/*_______________________________________________________*/

include "MiniComplex.h"

bool MiniComplex:: perator==(const MiniComplex & otherComplex)const

{ (1);}

MiniComplex:: MiniComplex(double real, double imag){realPart=real;imagPart=imag!}

MiniComplex MiniComplex:: operator+(const MiniComplex & otherComplex)const

{ MiniComplex temp;

temp. realPart=realPart+ otherComplex. realPart;

temp. imagPart=imagPart+ otherComplex. imagPart;

return temp;

}

MiniComplex MiniComplex::operator--(const MiniComplex & otherComplex)const

{ MiniComplex temp;

temp.realPart=realPart-otherComplex.realPart;

temp. imagPart=imagPart-otherCompler.imagPart;

return temp;

}

MiniComplex MiniComplex:: operator*(const MiniComplex& otherComplex)const

{ MiniComplex temp;

temp.realPart=(realPart* otherComplex.realPart)-(imag-Part* otherComplex.imag-Part);

temp imagPart=(realPart* otherComplex. imagPart)+(imag-Part *otherComplex.realPart);

return temp,

}

MiniComplex MiniComplex:: operator/(const MiniComplex& otherComplex)eonst

{ MiniComplex temp;

float tt;

tt=1/(otherComplex. realPart *otherComplex. realPart+otherComplex. imagPart* other Complex.imagPart);

temp. realPart=((realPart* otherComplex.realPart)+(imagPart* otherComplex.imagPart))*tt;

temp. imagPart=((imagPart * otherComplex.realPart)-(realPart* otherComplex.imagPart))*tt;<

请帮忙给出正确答案和分析,谢谢!

参考答案
您可能感兴趣的试题
  • 阅读以下说明和C函数,填补代码中的空缺(1)~(5),将解答填入答题纸的对应栏内。 【说明1】

  • 阅读以下说明和 C 代码,填补代码中的空缺,将解答填入答题纸的对应栏内。 【说明】 下面的代码

  • 阅读以下说明和C代码,填补代码中的空缺,将解答填入答题纸的对应栏内。【说明1】 递归函数is_elem(

  • 试题二(共15分)阅读以下说明、C程序代码和问题1至问题3,将解答写在答题纸的对应栏内。【说明1】设在

  • 试题五(共15分)阅读以下说明和C++代码,填补C++代码中的空缺(1)~(6),将解答写在答题纸的对应栏内。

  • 阅读以下说明和C语言代码 回答问题1至问题3 将解答填入对应栏内。 【说明】 在实时系统中 许多控制