首页 > 计算机等级考试
题目内容 (请给出正确答案)
[主观题]

有如下程序: ClassBase{ public: intdata; }; ClassDerived1:publicBase{}; ClassDer

有如下程序:

ClassBase{

public:

intdata;

};

ClassDerived1:publicBase{};

ClassDerived2:protectedBase{};

intmain(){

Derived1d1;

Derived2d2;

d1.data=0;//①

d2.data=0;//②

return0;

}

下列关于程序编译结果的描述中,正确的是()。

A.①②皆无编译错误

B.①有编译错误,②无编译错误

C.①无编译错误,②有编译错误

D.①②皆有编译错误

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

有如下程序:

include<iostream.h>

usingnamespacestd;

classBase

{

public:

Base(){cout<<"BB";f();}

voidf(){cout<<"BF";}

};

classDerived:publicBase

{

public:

Derived(){cout<<"DD";}

voidf(){eout<<"Df";}

};

intmain(){Derivedd;return0;}

执行上面的程序将输出()。

A.BBBfDD

B.BBDfDDDf

C.DD

D.DDBBBf

点击查看答案
第2题
有如下程序: #include<iostream>usingnamespacestd; classBASE{public: ~BASE(){cout<&

有如下程序:

#include<iostream>

usingnamespacestd;

classBASE{

public:

~BASE(){cout<<"BASE";}

};

classDERIVED:publicBASE{

public:

~DERIVED(){cout<<"DERIVED";}

};

intmain(){DERIVEDx;return0;)

执行后的输出结果是()。

A.BASE

B.DERlVED

C.BASEDERIVED

D.DERlVEDBASE

点击查看答案
第3题
有如下程序: #include<iostream> usingnamespacestd; classBase{ public: Base(intx=O)

有如下程序: #include<iostream> usingnamespacestd; classBase{ public: Base(intx=O){cout<<x;} }; classDerived:publicBase{ public: Derived(intx=O){cout<<x;}

private: Baseval; }; intmain(){ Derivedd(1); return0; } 程序执行后的输出结果是()。

A.100

B.000

C.010

D.001

点击查看答案
第4题
有如下程序: #include<iostream> usingnamespacestd; classBASE{ public: ~BASE(){cout
<<"BASE";} }; classDERIVED:publicBASE{ public: ~DERIVED(){cout<<"DERIVED";} }; intmain(){DERIVEDx;return0;) 执行后的输出结果是()。

A.BASE

B.DERlVED

C.BASEDERIVED

D.DERlVEDBASE

点击查看答案
第5题
有如下程序 #includeusingnamespacestd;classBase{protected;Base(){cout<<’A’;}B

有如下程序

#include

using namespace std;

class Base{

protected;

Base(){cout<<’A’;}

Base(char c){cout<};

class Derived; public Base{

public:

Derived(char c ){cout <};

int main(){

Derived d1(‘B’);

return 0;

}

执行这个程序屏幕上将显示输出______。

A.B

B.BA

C.AB

D.BB

点击查看答案
第6题
有如下程序: #include<iostream> using namespace std; classBase{ public: void fun
{ __________________ cout<<”Base::fun”<<endl;} }; class Derived:public Base{ public: voidfun{ cout<<”Derived::fun”<<endl: } }; int main{ Derived d; A fun; return 0; } 已知其执行后的输出结果为: Base::fun Derived::fun 则程序中下画线处应填入的语句是()。

A. Base.fun;

B.Base::fun;

C.Base—>fun;

D.fun;

点击查看答案
第7题
有如下程序:#include <iostream.h>using namespace std;classBase{protected:int i:public:int j

有如下程序: #include <iostream.h> using namespace std; class Base { protected: int i: public: int j; }; class Derived: public Base { int m: public: int n; } int main() { Derived d: d.i=0; //[1] d.J=0; //[2] d.m=0; //[3] d.n=0: //[4] return 0; } 其中主函数中有两个赋值语句有错,这两个错误的赋值语句是

A.[1]和[2]

B.[1]和[3]

C.[2]和[3]

D.[2]和[4]

点击查看答案
第8题
有如下程序: #included<iostream>usingnamespacestd; classTestClass{private: intX,y; pu

有如下程序:

#included<iostream>

usingnamespacestd;

classTestClass

{private:

intX,y;

public:

TestClass(inti,intj)

{x=i;

y=j;}

voidprint()

{cout<<"printl"<<endl;}

voidprint()const

{cout<<"print2"<<endl;}};

intmain()

{constTestClassa(1,2);

print();

return0;}

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

A.printl

B.print2

C.printlprint2

D.程序编译时出错

点击查看答案
第9题
有下列程序: #include<iostream.h> using namespace std; classBase { protected: int i; public
: int j; }; classDerived:public Base { int m; public: intn; }; int

A.[1]和[2]

B.[1)和[3]

C.[2]和[3]

D.[2]和[4]

点击查看答案
第10题
有以下程序:#inClUde<iostream>usingnamespacestd;ClassBase{public: Base(intx) {a=x; } voidsh

有以下程序: #inClUde <iostream> using namespace std; Class Base { public: Base(int x) { a=x; } void show() { cout<<a; } private: int a; }; class Derived : public Base { public: Derived(int i) :Base(i+1),b(i){} void Show() { cout<<b; } private: int b; }; int main() { Base b(5),*pb; Derived d(1); pb=&d; pb->show(); return 0; } 运行后的输出结果是()。

A.1

B.5

C.2

D.0

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