首页 > 消防安全> 注册消防工程师
题目内容 (请给出正确答案)
[主观题]

有如下程序:#include <iostream.h>using namespace std;class Demo{public:Demo(){ cout<<"defau

有如下程序: #include <iostream.h> using namespace std; class Demo { public: Demo(){ cout<<"defautt constmctor\n"; } Demo(const Demo &x){cont<<"copy constmctor\n";} }; Demo userCode (Demo b){Demo c(b);return c;} int main() { Demo a,d; cout<<"calling userCode()\n"; d=userCode(a); return 0; } 执行上面程序的过程中,构造函数Demo()和Demo(const Demo&x)被调用的次数分别是()。

A.1和1

B.1和2

C.2和3

D.2和4

查看答案
答案
收藏
如果结果不匹配,请 联系老师 获取答案
您可能会需要:
您的账号:,可能还需要:
您的账号:
发送账号密码至手机
发送
安装优题宝APP,拍照搜题省时又省心!
更多“有如下程序:#include <iostream.h>usi…”相关的问题
第1题
有如下程序: #include<iostream>usingnamespacestd; classPair{intm,n; public; Pair(intj

有如下程序:

#include<iostream>

usingnamespacestd;

classPair{

intm,n;

public;

Pair(intj,intk):m(j),n(k){}

intget(){returnm;}

intget()const{returnm+n;}

};

intmain(){

Paira(3,5);

constPairb(3,5);

cout<<a.get()<<b.get();

return0;

}

运行时的输出结果是()。

A.33

B.38

C.83

D.88

点击查看答案
第2题
有如下程序:#include<iostream>using namespace std;class BASE{public:~BASE(){cout<<"BASE";}}

有如下程序: #include<iostream> using namespace std; class BASE{ public: ~BASE(){cout<<"BASE";} }; class DERIVED:public BASE{ public: ~DERIVED(){cout<<"DERIVED";} }; int main(){DERIVED x;return 0;} 执行后的输出结果是()。

A.BASE

B.DERIVED

C.BASEDERIVED

D.DERIVEDBASE

点击查看答案
第3题
有如下程序: #include<iostream>usingnamespacestd; classTest{public: Test(){n+=2;}~Tes

有如下程序:

#include<iostream>

usingnamespacestd;

classTest

{

public:

Test(){n+=2;}

~Test(){n-=3;}

staticintgetNum(){returnn;}

private:

staticintn;

};

intTest::n=1;

intmain()

{

Test*p=neWTest;

deletep;

cout<<"n="<<Test::getNum()<<endl;

return0;

}

执行该程序的输出结果是()。

A.n=0

B.n=1

C.n=2

D.n=3

点击查看答案
第4题
有如下程序:#include(iostream>using namespace std;Class Test{public:Test(){n+=2;}~Test(){n-

有如下程序: #include(iostream> using namespace std; Class Test { public: Test() {n+=2;} ~Test() {n-=3;) static int getNum() {return n;} private: static int n; }; int Test::n=1; int main() { Test*p=new Test;

A.n=0

B.n=1

C.n=2

D.n=3

点击查看答案
第5题
有如下程序: #include<iostream> usingnamespacestd; voidf1(int&X,int&y){intz=X;x=y;y

有如下程序: #include<iostream> usingnamespacestd; voidf1(int&X,int&y){intz=X;x=y;y=z} voidf2(intX,inty){intz=x;x=y;y=z} intmain(){ intx=10,y=26 f1(x,y); f2(X,y); cout<<y<<endl; return0; } 运行时的输出结果是()。

A.10

B.16

C.26

D.36

点击查看答案
第6题
编程设计一个简单的计算器程序,要求用户从键盘输入如下形式的表达式:操作数1 运算符op 操作数2

编程设计一个简单的计算器程序,要求用户从键盘输入如下形式的表达式:

操作数1 运算符op 操作数2

然后,计算并输出表达式的值

指定的运算符为:

加()

减(-)

乘(*)

除(/)

代码如下,所给程序是否存在错误,若有,找出错误所在并改正。

A、default分支缺少break语句

B、第20行语句有错误,改成:

if (data2=0) printf("Division by zero!\n");

else printf("%f/%f = %f\n", data1, data2, data1/data2);

C、没有错误

D、第20行语句有错误,改成:

if (fabs(data2)<=eps) printf("division by zero!\n");

else printf("%f/%f = %f\n", data1, data2, data1/data2);

同时,第1行语句下方应加入

#include

#define EPS 1e-6

点击查看答案
第7题
请写出如下程序的输出结果:#include void Swap( int &a, int & b);void main(){int
请写出如下程序的输出结果:#include void Swap(int &a, int & b);void main(){int

请写出如下程序的输出结果:

#include void Swap(int &a, int & b);void main(){int x(10 ), y(7 );

cout<< "x="<< x<< " y="<< y<< endl;Swap(x , y );cout<< "x="<< x<< " y="<< y<< endl;

}void Swap(int & a, int & b){ int temp; temp = a ; a=b ; b=temp ; }

点击查看答案
第8题
请写出如下程序的输出结果:#include class R{public:R(int r1,int r2) {R1=r1;R2=r2;}void p
请写出如下程序的输出结果:#include class R{public:R(int r1,int r2) {R1=r1;R2=r2;}void p

请写出如下程序的输出结果:

#include class R{public:R(int r1,int r2) {R1=r1;R2=r2;}void print();

void print() const;private:int R1,R2;};void R::print(){cout<< R1<< ":"<< R2<< endl;

}void R::print() const{cout<< R1<< ";"<< R2<< endl;}void main(){R a(5,4);a.print();

const R b(20,52);b.print();}

点击查看答案
第9题
如下程序的输出结果是#include<stdio.h>main(){ char ch[2][5]={"6937","8254"},*p[2];int i,j,s=0;for(i=0;i<2;i++) p[i]=ch[i];for(i=0;i<2;i++)for(j=0;p[i][j]>′\0′;j+=2)s=10*s+p[i][j]-′0′;printf("%d\n",s);}

A.69825

B.63825

C.6385

D.693825

点击查看答案
第10题
请编写一个函数fun(),它的功能是:根据以下公式求π的值(要求满足精度0.005,即某项小于0.005时停止

请编写一个函数fun(),它的功能是:根据以下公式求π的值(要求满足精度0.005,即某项小于0.005时停止迭代)。

π/2=1+1/3+1*2/(3*5)+1*2*3/(3*5*7)+1*2*3*4/(3*5*7*9)+…

+1*2*3*…*n/(3*5*7*…*(2n+1))

程序运行后,如果输入精度0.0005,则程序输出3.14…。

注意:部分源程序给出如下。

请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。

试题程序:

include<conio.h>

include<math.h>

double fun(double eps)

{

}

main()

{

double x;

printf("Input eps: ");

scanf("%1f", &x);

printf("\neps=%1f,PI=%1f\n",x,fun(x));

}

点击查看答案
退出 登录/注册
发送账号至手机
密码将被重置
获取验证码
发送
温馨提示
该问题答案仅针对搜题卡用户开放,请点击购买搜题卡。
马上购买搜题卡
我已购买搜题卡, 登录账号 继续查看答案
重置密码
确认修改