首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
下面是复数类complex的定义,其中作为友元函数重载的运算符“--”的功能是将参数对象的实部减1,然后返回对该对象的引用:请补充完整。 class complex { private: int real; int
下面是复数类complex的定义,其中作为友元函数重载的运算符“--”的功能是将参数对象的实部减1,然后返回对该对象的引用:请补充完整。 class complex { private: int real; int
admin
2009-02-15
23
问题
下面是复数类complex的定义,其中作为友元函数重载的运算符“--”的功能是将参数对象的实部减1,然后返回对该对象的引用:请补充完整。
class complex
{
private:
int real;
int imag;
public:
complex(int r=0,int i=0):real(r),imag(i){}
void show()
{
cout<<real<<(imag<0?"-":"+")<<imag<<’i’;
}
【 】;
};
complex& operator--(complex &C)
{
c.real--;
return c;
}
选项
答案
friend complex& operator--(complex&)
解析
本题考核运算符重载的定义。程序要填入的是运算符函数operator--在类 complex中的声明,运算符“--”是作为友元函数重载的。根据题目给出的条件,易得到答案。
转载请注明原文地址:https://kaotiyun.com/show/Zzjp777K
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
以下选项中,不合法的C语言用户标识符是()。
有以下程序:#include<stdio.h>#include<string.h>main(){charstr[][20]={"One*World","One*Dream!"),*p=str[1];
设有定义doublea[10],*s=a;以下能够代表数组元素a[3]的是
下列模式中,能够给出数据库物理存储结构与物理存取方法的是()。
以下语句定义正确的是()。
下列给定程序中,函数fun的功能是:在形参s所指字符串中寻找与参数c相同的字符,并在其后插入一个与之相同的字符,若找不到相同的字符则不做任何处理。例如,若s所指字符串为“baacda”,c中的字符为a,执行后s所指字符串为“baaaacdaa”。
运动会中一个运动项目可以有多名运动员参加,一个运动员可以参加多个项目。则实体项目和运动员之间的联系是
我们所写的每条C语句,经过编译最终都将转换成二进制的机器指令。关于转换以下说法错误的是
下列说法正确的是()。
随机试题
敲钟人卡西莫多的形象出自文学大师雨果创作的()。
骨骼摄影距离的最佳选择是
患者腹大坚满,胸脘痞闷,烦热口苦,身目发黄,小便短赤,大便干结,舌红苔黄腻,脉弦数。其证型是
用药咨询是药师应用所掌握的药学知识和药品信息,承接公众对药物治疗和合理用药的咨询服务,对临床合理用药有关键性作用。根据药物咨询对象的不同,可以将其分为患者、医师、护士和公众的用药咨询。下列多由患者提出的用药咨询内容是()。
2011年9月1日,某法院受理了湘江服装公司的破产申请并指定了管理人,管理人开始受理债权申报。下列哪些请求权属于可以申报的债权?
世界银行贷款对已订立贷款契约而未使用的部分,要按年征收( )的承诺费。
ABC公司下设A、B两个投资中心,A投资中心的平均净经营资产为700万元,部门投资报酬率为20%;B投资中心的部门投资报酬率为22%,剩余收益为105万元;ABC公司对A中心要求的平均最低部门税前投资报酬率为15%,对B中心要求的平均最低部门税前投资报酬率
下列不属于佛教四大名山的是()。
下关于查询的描述正确的是______。
Theteacher’svoicewassopleasantthatthelittleboyfeltat______withheratonce.
最新回复
(
0
)