重要提示: 请勿将账号共享给其他人使用,违者账号将被封禁!
查看《购买须知》>>>
找答案首页 > 全部分类 > 求职面试
搜题
网友您好, 请在下方输入框内输入要搜索的题目:
搜题
题目内容 (请给出正确答案)
[单选题]

对于下面代码说法正确的有 class A { public: A(int x) {} }; class B: public A{ public: B(){} }; int main() { B b; }

A.编译错误

B.编译正确,但是运行时没有输出信息

C.在第三行代码后加上 A() = default; 就能编译通过

D.在第二行代码后加上 A() {} 就能编译通过

E.第七行改成 B():A(0){} 就能编译通过

查看答案
更多“对于下面代码说法正确的有 class A { public: A(int x) {} }; class B: public A{ public: B(){} }; int main() { B b; …”相关的问题

第1题

下面的例子中

using System;

class A

{

public static int X;

static A(){

X=B.Y+1;

}

}

class B

{

public static int Y=A.X+1;

static B(){}

static void Main(){

Console.WriteLine("X={0},Y={1}",A.X,B.Y);

}

}

产生的输出结果是什么?

点击查看答案

第2题

下面的例子中

using System;

class A

{

public static int X;

static A(){

X=B.Y+1;

}

}

class B

{

public static int Y=A.X+1;

static B(){}

static void Main(){

Console.WriteLine("X={0},Y={1}",A.X,B.Y);

}

}

产生的输出结果是什么?

点击查看答案

第3题

有以下类定义: class A{int x;}; class B:virtual public A{int y;}; class C:virtual public A{int z;}; class D:public B, public C{}; 则对于 D 类对象 d,以下正确的选项是( )。

A、有 3 个成员

B、有 4 个成员

C、没有成员

D、有 2 个成员

点击查看答案

第4题

对下面的程序段下面的说法正确的是()。 class A { int ...

对下面的程序段下面的说法正确的是()。 class A { int x, y; public: A(int a, int b) { x=a; y=b;} void show() { cout< <x> << “,”< <y> < <endl; } void set(int a, int b) { x="a;" y="b;" main() a obj; obj.set(3, 5); obj.show();> A、编译时报错,程序无法运行

B、编译无错,运行正常,输出3,5

C、编译无错,运行时报错

D、编译时报警告错,但运行正常,输出3,5

点击查看答案

第5题

有以下程序:

include<iostream.h>

class A

{

int x;

public:

A(int a)

{

x=a;

}

friend class B;

}

class B{

public:

void print(A a){

a. x--;

cout<<a.x<<end1;

}

};

void main()

{

A a(10);

B b;

b.print(a) ;

}

程序执行后的输出结果是【 】。

点击查看答案

第6题

下面程序段的输出结果为 package test; public class Class A { int x=20; static int y=6; public static void main(String args[]) { Class B b=new Class B(); b.go(10); System.out.println("x"+b.x); } } class ClassB { int x; void go(int y) { ClassA a=new ClassA(); x=a.y; } }

A.x=10

B.x-20

C.x=6

D.编译不通过

点击查看答案

第7题

下面程序段的输出结果为 package test; public class ClassA { int x=20; static int y=6; public static void main(String args[]) { ClassB b=new ClassB(); b.go(10); System.out.println("x="+b.x); } } class ClassB { int x; void go(int y) { ClassA a=new ClassA(); x=a.y; } }

A.x=10

B.x=20

C.x=6

D.编译不通过

点击查看答案

第8题

有如下类定义关系: class A { public: int x; }; class B: public A { int y; }; class C:public
A { int z; }; class D:public B, public C { }; 试问,若有下列类应用,其输出结果是( ) D d; d.x=5; cout< <d.x;>

A、没有输出

B、55

C、编译错误

D、5

点击查看答案

第9题

在下面的例子里

using System;

class A

{

public A(){

PrintFields();

}

public virtual void PrintFields(){}

}

class B:A

{

int x=1;

int y;

public B(){

y=-1;

}

public override void PrintFields(){

Console.WriteLine("x={0},y={1}",x,y);

}

当使用new B()创建B的实例时,产生什么输出?

点击查看答案

第10题

在下面的例子里

using System;

class A

{

public A(){

PrintFields();

}

public virtual void PrintFields(){}

}

class B:A

{

int x=1;

int y;

public B(){

y=-1;

}

public override void PrintFields(){

Console.WriteLine("x={0},y={1}",x,y);

}

当使用new B()创建B的实例时,产生什么输出?

点击查看答案
下载上学吧APP
客服
TOP
重置密码
账号:
旧密码:
新密码:
确认密码:
确认修改
购买搜题卡查看答案
购买前请仔细阅读《购买须知》
请选择支付方式
微信支付
支付宝支付
选择优惠券
优惠券
请选择
点击支付即表示你同意并接受《服务协议》《购买须知》
立即支付
搜题卡使用说明

1. 搜题次数扣减规则:

功能 扣减规则
基础费
(查看答案)
加收费
(AI功能)
文字搜题、查看答案 1/每题 0/每次
语音搜题、查看答案 1/每题 2/每次
单题拍照识别、查看答案 1/每题 2/每次
整页拍照识别、查看答案 1/每题 5/每次

备注:网站、APP、小程序均支持文字搜题、查看答案;语音搜题、单题拍照识别、整页拍照识别仅APP、小程序支持。

2. 使用语音搜索、拍照搜索等AI功能需安装APP(或打开微信小程序)。

3. 搜题卡过期将作废,不支持退款,请在有效期内使用完毕。

请使用微信扫码支付(元)
订单号:
遇到问题请联系在线客服
请不要关闭本页面,支付完成后请点击【支付完成】按钮
遇到问题请联系在线客服
恭喜您,购买搜题卡成功 系统为您生成的账号密码如下:
重要提示: 请勿将账号共享给其他人使用,违者账号将被封禁。
发送账号到微信 保存账号查看答案
怕账号密码记不住?建议关注微信公众号绑定微信,开通微信扫码登录功能
警告:系统检测到您的账号存在安全风险

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

- 微信扫码关注上学吧 -
警告:系统检测到您的账号存在安全风险
抱歉,您的账号因涉嫌违反上学吧购买须知被冻结。您可在“上学吧”微信公众号中的“官网服务”-“账号解封申请”申请解封,或联系客服
- 微信扫码关注上学吧 -
请用微信扫码测试
选择优惠券
确认选择
谢谢您的反馈

您认为本题答案有误,我们将认真、仔细核查,如果您知道正确答案,欢迎您来纠错

上学吧找答案