皮皮学,免费搜题
登录
logo - 刷刷题
搜题
【简答题】
阅读以下程序说明和C++程序,将程序段中(1)~(5)空缺处的语句填写完整。 【说明】 以下【C++程序】实现一个简单的小型复数类MiniComplex,该复数类能进行输入、输出、复数的加法、减法、乘法和除法运算,还可以进行复数的相等比较。 【C++程序】 ifndef H_MiniComplex define H_MiniComplex include <iostream> using namespace std; class MiniComplex{ public: //重载流插入和提取运算符 (1) ostream&operator<<(ostream &osObject,const MiniComplex&complex){ osObject<<'('<<complex.realPart<<'+'<<complex.imagPart<<'i'<<')'; return osObject; } (2) istream&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&otherComplex)const; //重载运算符* MiniComplex operator/(const MiniComplex&otherComplex)const; //重载运算符/ bool perator==(const MiniComplex&otherComplex)const; //重载运算符== private : double (3); double imagPart; }; end if include 'MiniComplex.h' bool MiniComplex::operator==(const MiniComplex&otherComplex)const{ return(realPart==otherComplex.realPart&&imagPart==ortherComplex.imagPart); } MiniComplex::MiniComplex(double real,double imag){ realPart== real; imagPart==imagPart; } MiniComplex MiniComplex::operator+(const MiniComplex&otherComplex)const{ MiniComplex temp; temp.realPart = realPart+ortherComplex. realPart; temp.imagPart = imagPart +ortherComplex. imagPart; return temp; } (4) { MiniComplex temp; temp.realPart= realPart-ortherComplex. realPart; temp.imagPart = imagPart-ortherComplex. imagPart; return temp; } MiniComplex MiniComplex::operator*(const MiniComplex&otherComplex)const{ MiniComplex temp; temp.realPart = (realPart*ortherComplex. realPart)-(imagPart *ortherComplex.imagPart); temp.imagPart = (realPart*ortherComplex. imagPart)+(imagPart *ortherComplex.realPart); return temp; } MiniComplex MiniComplex::operator/(const MiniComplex&otherComplex)const{ MiniComplex temp; float tt; tt=1/(ortherComplex.realPart*ortherComplex.realPart+ortherComplex.imagPart *ortherComplex. imagPart); temp.realPart=((realPart*ortherComplex, realPart)+(imagPart *ortherComplex. imagPart))*tt; temp.imagPart =((imagPart *ortherComplex. realPart)-(realPart*ortherComplex. imagPart))*tt; return temp; } include <iostream> include <MiniComplex.h> using namespace std; int main(){ MiniComplex numl(23, 34),num2(56, 35); cout<<'Initial Value of num1='<<num1<<'/n Initial Value of num2='<<num2<<end1; cout<<num1<<'+'<<num2<<'='<<num1+num2<<end1; //使用重载的加号运算符 cout<<num1<<'-'<<num2<<'='<<num
手机使用
分享
复制链接
新浪微博
分享QQ
微信扫一扫
微信内点击右上角“…”即可分享
反馈
参考答案:
举一反三
【单选题】小儿高热易发生
A.
昏迷
B.
体重下降
C.
惊厥
D.
脱水
【多选题】目前认为能较好地解释大部分实验事实的理论是( )
A.
成相膜理论
B.
转化膜理论
C.
吸附理论。
【单选题】水泥稳定材料击实试验的试样放入烘箱检测含水量时,烘箱温度为(   )℃
A.
110
B.
100
C.
80
D.
20
【简答题】承包人在签订合同时应该注意哪几个重要方面?哪些问题需要约定才对承包人有利?
【简答题】下列物质在生物体内的转化过程中需要ATP的是                (   ) A .葡萄糖→乙醇+二氧化碳                B.葡萄糖→乳酸 C .二氧化碳+水→葡萄糖                  D.蛋白质→氨基酸
【单选题】签订国际贸易合同时应该注意,违约金条款一般应该注意,不属于的是()
A.
不要遗漏
B.
内容要全面
C.
幅度不要太高
D.
实际上是一项免责条款
【单选题】据世界贸易组织(WTO)统计,( )已连续21年成为遭遇反倾销调查最多的国家,连续10年成为遭遇反补贴调查最多的国家。
A.
中国
B.
美国
C.
俄罗斯
D.
日本
【单选题】下列物质在生物体内转化过程中,需要ATP的是 [     ]
A.
水在光下分解
B.
葡萄糖分解成二氧化碳和水
C.
胃蛋白酶分解成氨基酸
D.
三碳化合物形成葡萄糖
【判断题】任何情况下,围岩都不允许欠挖。
A.
正确
B.
错误
【多选题】喷涂银粉漆时,造成银粉不匀的原因有{.XZ}
A.
喷涂过湿
B.
涂膜厚度不均匀
C.
喷枪雾化差
D.
行枪不均匀
E.
环境温度过低
相关题目:
参考解析:
知识点:
题目纠错 0
发布
创建自己的小题库 - 刷刷题