题目内容 (请给出正确答案)
[主观题]

有以下程序: #include<iostream> usingnamespacestd; classsample { private: intn; p

ublic: sample(){} sample(intm) { n=m: } sampleadd(samplesl,samples2) { this->n=s1.n+s2.n; return(*this); } voiddisp() { cout<<"n="<<n<<endl; } }; intmain() { samples1(10),s2(5),s3; s3.add(s1,s2); s3.disp(); return0: } 程序运行后,输出的结果是()。

A.n=10

B.n=5

C.n=20

D.n=15

提问人:网友huazhaoshi 发布时间:2022-01-06
参考答案
查看官方参考答案
如搜索结果不匹配,请 联系老师 获取答案
更多“有以下程序: #include<iostream> usin…”相关的问题
第1题
程序 #include<iostream> using namespace std; void fun(int &a,int &b) { int p; p=a; a=b; b=p; } void exchange(int &a,int &b,int &c) { if(a<b)fun(a,b); } int main() { a="5,b=9,c=6;" exchange(a,b,c); ,b="&lt;&lt;b&lt;&lt;" ,c="&lt;&lt;c&lt;&lt;endl; return 0;} 程序运行时输出的结果是什么?&lt;br&gt;&lt;p class=" answer">

1、详见附件。 要求按照上机要求,提交实验报告word和程序的压缩包,包括封面、实验目的、实验内容(题目、代码、结果及分析)、实验步骤、实验心得体会、建议。 请同学们按照评分标准进行互评。

点击查看答案
第2题
下列程序运行结果是 。 class Base { public: void fun1(){cout<<"base\n";} virtual void }; derived:public base { public: f(base &b){ b.fun1(); b.fun2(); } main(){ derived obj; f(obj);>
点击查看答案
第3题
include

using namespace std;

int fun1(int);

void main()

{

int i=12;

___________;

___________;

cout$amp;}

int fun1(int k)

{

k=k*2+1;

return k;

}

点击查看答案
第4题
有如下程序: #inClude using namespaCe std; Class Sample{ friend long fun(Sample S); publiC: Sample(10ng A.{x=a;} private: long X; }; long fun(Sample S){ if(S.x<2)return l; return S.X*fun(Sample(s.x-1)); } int main() { int sum=0; for(int i=0;i<6;i++) {sum+=fun(Sample(i));} Cout$amp;A.120

B.16

C.154

D.34

点击查看答案
第5题
有如下程序: #include using namespace std; class Base { public: void funl{cout$amp;A.Base Base

B.Base Derived

C.Derived Base

D.Derived Derived

点击查看答案
第6题

以下程序的输出结果是()。 #include <iostream> using namespace std; void main( ) { int a[3][4]={ 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23}, (*p)[4]=a; int i, j, k=0; for(i=0; i<3; i++) for(j="0;" j++) k="k+*(*(p+i)+j);"> < <endl;> A、60

B、68

C、99

D、108

点击查看答案
第7题

有如下程序: #include <iostream> using namespace std; class TestClass { public: virtual void fun1( ) { cout<<"fun1testclass"< } virtual void fun2( ) { }; testclass1:public testclass fun1( fun2(int x) int main( obj1,*p; testclass1 obj2; p="&amp;obj2;" p-> fun1(); p->fun2(); return 0; } 该程序执行后的输出结果是( )。

A、fun1TestClass1 fun2TestClass

B、fun1TestClass1 fun2TestClass1

C、fun1TestClass fun2TestClass

D、fun1TestClass fun2TestClass1

点击查看答案
第8题
有以下程序: #include 〈iostream〉 using namespace std; class A { public: virtual void setx(int i,int j=0) { x=i; y=j; } virtual void print()=0; protected: int x,y; }; class B : public A { public: void print() { cout〈〈x*x〈〈", "; } }; class C : public A { public: void print() { cout〈〈x*x*x〈〈end1; } }; int main() { A *pa; B b; C c; pa=&b; pa->setx(5); pa->print (); pa=&c; pa->setx(2); pa->print(); return 0; } 程序运行后的输出结果是()。

A.25,8

B.2,5

C.5,2

D.8,25

点击查看答案
第9题
有如下程序: #include<iostream> using namespace std; class A{ public: virtual void f( ){cout<<1;} void }; b: public a{ public: virtual f( g( show(a &a) { a.f( ); a.g( } int main( ){ b b; show(b); return 0;> A、32

B、12

C、34

D、14

点击查看答案
第10题

下列程序的运行结果是()。 #include <iostream> using namespace std; void main( ) { int a[]={2, 4, 6, 8, 10}, y=1, x, *p=&a[1]; for( x=0; x<3; x++) y+="*(p+x);"> < <endl;> A、17

B、18

C、19

D、20

点击查看答案
账号:
你好,尊敬的用户
复制账号
发送账号至手机
密码将被重置
获取验证码
发送
温馨提示
该问题答案仅针对搜题卡用户开放,请点击购买搜题卡。
马上购买搜题卡
我已购买搜题卡, 登录账号 继续查看答案
重置密码
确认修改
欢迎分享答案

为鼓励登录用户提交答案,简答题每个月将会抽取一批参与作答的用户给予奖励,具体奖励活动请关注官方微信公众号:简答题

简答题官方微信公众号

警告:系统检测到您的账号存在安全风险

为了保护您的账号安全,请在“简答题”公众号进行验证,点击“官网服务”-“账号验证”后输入验证码“”完成验证,验证成功后方可继续查看答案!

微信搜一搜
简答题
点击打开微信
警告:系统检测到您的账号存在安全风险
抱歉,您的账号因涉嫌违反简答题购买须知被冻结。您可在“简答题”微信公众号中的“官网服务”-“账号解封申请”申请解封,或联系客服
微信搜一搜
简答题
点击打开微信