首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有以下程序,输出结果( )。 #include<iostream> using namespace std; class Complex { public: Complex(double r=0,double i=
有以下程序,输出结果( )。 #include<iostream> using namespace std; class Complex { public: Complex(double r=0,double i=
admin
2012-01-20
50
问题
有以下程序,输出结果( )。 #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+i
B、2i+5
C、6+1i
D、1i+5
答案
C
解析
由主函数入手,调用“Complex a=Complex(1,1)+Complex(5);”,实际是“Complex a=Complex(1,1)+Complex(5,0);”,调用“return Complex(re+c.re,im+c.im);”结果为:6+1i。
转载请注明原文地址:https://kaotiyun.com/show/5WVp777K
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
以下叙述中正确的是
有以下程序#include<stdio.h>voidfun(char**p){++p;printf("%s\n",*p);}main(){char*a[]={"Morning","Aft
下列关于C语言文件的叙述中正确的是()。
若有定义语句:intx=12,y=8,z;在其后执行语句z=0.9+x/y则z的值为()。
下列语句组中,正确的是()。
下列叙述中,不属于设计准则的是()。
下面不属于需求分析阶段任务的是()。
算法的时间复杂度是指
以下对联合类型叙述正确的是()。
设有下面的定义:structst{inta;floatb:}d;int*p;要使p指向结构变量d中的a成员,正确的赋值语句是()。
随机试题
通过坐骨小孔的结构是()
最可能的临床诊断是根据诊断,首选的治疗方法是
病人告诉医生,每当他听到自来水的流动声时,就同时听到有人议论他的声音当某一感觉器官处于功能活动状态时,出现涉及另一感觉器官的幻觉
根据《造价工程师注册管理办法》的规定,造价工程师享有的权利包括( )。
非关税壁垒就是指除了关税以外的所有限制进口的措施。()
Ourancestorscelebrated______birthof______childbygivingawayredeggs.
Alllivingthingsneedair______.______hascleanerair.
Liberal(自由)educationisbecomingthetaskofteachers.Itis【C1】______notonlytoteachandlearnknowledge,butalsotodevel
InIreland,______experiencedthefastestgrowth.
PreparingChildrentoBeSafeatCollege[A]Moneycanbuymanythingstohelpchildrenexcelacademically,liketutorsandpriv
最新回复
(
0
)