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

下面程序的运行结果为()。 class A{ static int n; public: A(){n

下面程序的运行结果为()。 class A{ static int n; public: A(){n=1;} A(int num){n=num;} void print(){cout<<n;} } A::n=0; void main(){ A a,b(2); a.print(); b.pint(); }

A.12

B.11

C.22

D.21

提问人:网友dcmztc2008 发布时间:2022-01-07
参考答案
查看官方参考答案
如搜索结果不匹配,请 联系老师 获取答案
更多“下面程序的运行结果为()。 class A{ static …”相关的问题
第1题
编译并运行下面的程序,运行结果是( )。 public class A { public static void main(String args[]) { A a = new A(); a.method(8); } void method(int i) { System.out.println("int:" + i); } void method(long i) { System.out.println("long: " + i); } }

A、程序可以编译运行,输出结果为:“int: 8”

B、程序可以编译运行,输出结果为:“long: 8”

C、程序有编译错误,因为两个method()方法必须定义为静态(static)的

D、程序可以编译运行,但是没有输出

点击查看答案
第2题
下面程序的运行结果是()。 #include<iostream> using namespace std; class A { int a; public: A(){a=0;1 A(int aa ) {a=aa;} virtual void show() { cout<<a>>"";} }; class B:public A int b: public: B(){b=0:} B(int bb) {b=bb;} void show() {cout<<b>>" ";} }; class C:public B { int c; public: C(int cc) { c=cc;} void show() {cout<<c>>endl;} }; void main() { A a(8 ),*p;B b(9 );C c(10 ); p=&a; p->show(); p=&b; p->show(); p=&c; p->show(); }

A.8 8 8

B.8 9 10

C.0 0 10

D.10 10 10

点击查看答案
第3题
下面程序的运行结果为

#include

class A

{

public:

A(){cout$amp;~A(){cout$amp;}

class B:public A

{

public:

B(){cout$amp;~B(){cout$amp;}

void main()

{

B b;

}

A.1234

B.1324

C.1342

D.3142

点击查看答案
第4题
下面程序输出的结果为()。

#include"iostream.h"

classA

{public:

A(){cOUt$amp;~A(){}};

ClaSSB:publicA

{public:

B(){cout$amp;~B(){}};

voidmain()

{A*P;

P=newB:

B*q:

q=newB;}

A.CLASSB

B.CLASSA CLASSB CLASSB

C.CLASSA CLASSB CLASSA CLASSB

D.CLASSA CLASSB CLASSB CLASSB

点击查看答案
第5题
下面程序的运行结果为()。 #include class A { int hum; public: A(int i){nuln=i;} A(A&A.{num=a.num十+;} void print{eout(

A.11

B.12

C.21

D.22

点击查看答案
第6题
下面程序的结果是 ______。 #include<iostream.h> class A{ public: virtual void fun()=0{}; }; class B:public A{ public: void fun () {cout<< "new file" ;} }; class C: public A{ public: void fun (){cout<<"open file"<< " " } }; class D: public A{ public: void fun () {cout<< "save file\n" ;} }; void main() { A a,*p; B b; C c; D d; p=&c; p->fun (); p=&b; p->fun (); p=&d; p->fun(); }

A.new file open file save file

B.new file new file new file

C.编译出错

D.open file new file save file

点击查看答案
第7题
下列程序运行结果为____________ class A{ public: ~A( ){cout<<"a"; } }; char fun0() { a a1; throw('e'); return '0'; int main(){ try{ catch(char c) 0;>
点击查看答案
第8题
下面程序的运行结果为()。 #include class A static int n; public: A{n=1;} A(int num){n=hum;} void print{cout$amp;A.11

B.13

C.23

D.33

点击查看答案
第9题
请阅读下述代码,写出程序执行的结果

#include

using namespace std;

class CBase

{

public:

virtual void print()

{

cout$amp; }

void DoPrint()

{

print();

}

};

class CChild1: public CBase

{

public:

virtual void print()

{

cout$amp; }

};

class CChild2: pu

{

public:

virtual void pri

{

cout$amp; }

};

void DoPrint(CB

{

base->DoPrint

}

void main()

{

CBase* base =

CChild1* child

CChild2* child

DoPrint(child1

DoPrint(child2

DoPrint(base);

delete base;

base = child1;

base->print();

delete child1;

delete child2;

}

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

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

简答题官方微信公众号

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

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

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