网友您好, 请在下方输入框内输入要搜索的题目:

题目内容 (请给出正确答案)

有如下程序:

#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


参考答案

更多 “ 有如下程序:#includeiostreamusingnamespacestd;classBase{public:Base(intx=O){coutx;}};classDerived:publicBase{public:Derived(intx=O){coutx;}private:Baseval;};intmain(){Derivedd(1);return0;}程序执行后的输出结果是( )。A.100B.000C.010D.001 ” 相关考题
考题 有如下程序:includeiostream.husingnamespacestd;classBase{public:Base(){cout<<BB;f();}voidf(){cout<<BF;}};classDerived:publicBase{public:Derived(){cout<<DD;}voidf(){eout<<Df;}};intmain(){Derivedd;return0;}执行上面的程序将输出( )。A.BBBfDDB.BBDfDDDfC.DDD.DDBBBf

考题 有如下程序:includeusing namespace std;Class Base{public:Base(){cout 有如下程序: #include<iostream.h> using namespace std; Class Base { public: Base(){cout<<“BB”;f();} void{(){cout<<“BF”;} }; class Derived:public Base { public: Derived(){cout<<“DD”;} void f(){cout<<“Df”;) }; int mainA.BBBfDDB.BBDfDDDfC.DDD.DDBBBf

考题 有如下程序: #include<iostream) using namespace std; classBASE{ public: ~BASE(){cout<<“BASE”;} }; class DERIVED:public BASE{ public: ~DERIVED(){COUt<<“DERIVED”;} }; int main(){DERIVED x;return 0;} 执行后的输出结果是( )。A.BASEB.DERIVEDC.BASEDERIVEDD.DERIVEDBASE

考题 有如下程序:include using namespace std;class Base{public:Base(){cout 有如下程序:#include <iostream>using namespace std;class Base{ public: Base(){cout<<"BB"; f(); } Void f(){cout<<"Bf"; }};class Derived: public Base{ public: Derived() { cout<<"DD"; } void f() { cout<<"Df"; }};int main() { Derived d; return 0; }执行上面的程序将输出( )。A.BBBfDDB.BBDfDDDfC.DDD.DDBBBf

考题 有如下程序: include using namespace std; class BASE { public 有如下程序: #include<iostream> using namespace std; class BASE { public: ~BASE(){cout<<"BASE";} }; class DERIVED:public BASE { public: ~DERIVED(){cout<<"DERIVED";} }; int main(){DERIVEDx;retum 0;} 执行后的输出结果是A.BASEB.DERIVEDC.BASEDERIVEDD.DERIVEDBASE

考题 有如下程序:includeusing namespace std;class Base{protected:Base(){cout 有如下程序: #include<iostream> using namespace std; class Base{ protected: Base(){cout<<'Base';} Base(char c){cout<<c;} }; class Derived:public Base{ public: Derived(char c){cout<<c;} }; int main(){ Derived d('Derived'); return 0; } 执行这个程序屏幕上将显示输出( )。A.DerivedB.DerivedBaseC.BaseDerivedD.DerivedDerived

考题 如下程序的输出是includeusing namespace std;class Base{public:Base( ){cout 如下程序的输出是 #include<iostream> using namespace std; class Base{ public: Base( ){cout<<"BB";f( );} void f( ){cout<<"Bf";} }; class Derived:public Base{ public: Derived( ){eout<<"DD";} void f( ){cout<<"Df";} }; int main( ){Derived d;return 0;}A.BBBff)DB.BBDfDDDfC.DDD.DDBBBf

考题 有如下程序:includeusing namespace std;class Base{public:Base(int x=0){cout 有如下程序: #include<iostream> using namespace std; class Base{ public: Base(int x=0){cout<<x;} }; class Derived:public Base{ public: Derived(int x=0){cout<<x;} private: Base val; }; int main( ){ Derived d(1); return 0; } 程序的输出结果是A.0B.1C.01D.001

考题 有如下程序:include using namespace std;class BASE{public:~BASE(){cout 有如下程序: #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.BASEB.DERIVEDC.BASEDERIVEDD.DERIVEDBASE

考题 有如下程序:includeusing namespace std;class BASE{public:~BASE( ){cout 有如下程序: #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.BASEB.DERIVEDC.BASEDERIVEDD.DERIVEDBASE

考题 有如下程序:include using namespace std;class Base{public:void fun() {cout 有如下程序:#include <iostream>using namespace std;class Base { public: void fun() {cout<<"Base:: fun"<<end1; }};class Derived: public Base ( public: void fun() { ____________________________ cout<<"Derived:: fun"<<end1; }};int main() { Derived d; D. fun(); return O;}已知其执行后的输出结果为:Base:: funDerived:: fun则程序中下划线处应填入的语句是( )。A.Base. fun ();B.Base:: fun ();C.Base->fun();D.fun()

考题 若有以下程序: #includeiostream usingnamespacestd; classBase {public: Base() {x=0;} intx;}; classDerivedl:virtualpublicBase {public: Derivedl() {x=10;}}; classDerived2:virtua11publicBase {public: Derived2() {x=20;}}; classDerived:publicDerivedl,protectedDerived2{};intmain() {Derivedobj; coutobj.xendl; return0;} 该程序运行后的输出结果是( )。A.20B.30C.10D.0

考题 下列程序中横线处应填入的语句是()。 classBase { public: voidfun(){cout"Baseoffun"endl;}}; classDerived:publicBase { voidfun() { //显示基类的成员函数fun cout"Derivedoffun"endl; } };A.fun();B.Base.fun();C.Base::fun();D.Base-fun();

考题 有如下程序: #includeiostream usingnamespacestd; classBASE{ public: ~BASE(){cout"BASE";} }; classDERIVED:publicBASE{ public: ~DERIVED(){cout"DERIVED";} }; intmain(){DERIVEDx;return0;) 执行后的输出结果是( )。A.BASEB.DERlVEDC.BASEDERIVEDD.DERlVEDBASE

考题 有如下程序: #includeiostream usingnamespacestd; classBase{ public: virtualvoidfunctionl(){cout'0';} voidfunction2(){out'1';} }; classDerived:publicBase{ oublic: voidfunctionl(){cout'2';} voidfunction2(){cout'3';} }; intmain(){ Base*p=newDerived(); p-functionl(); p-function2(); return0; } 运行时的输出结果是( )。A.01B.21C.03D.23

考题 下面程序的运行结果是( )。#includeiostream.hclassbase{protected:inta;public:base(){cout0;}};classbasel:virtualbase{public:basel(){cout1;}};classbase2:virtualbase{public:base2(){cout2;}};classderived:publicbasel,publicbase2{public:derived(){cout3;}};voidmain(){derivedobj;coutendl;}A.0123B.3120C.0312D.3012

考题 有如下程序: #includeiostream.h usingnamespacestd; classBase { public: Base(){cout"BB";f();} voidf(){cout"BF";} }; classDerived:publicBase { public:Derived(){cout"DD";} voidf(){eout"Df";} }; intmain(){Derivedd;return0;} 执行上面的程序将输出( )。A.BBBfDDB.BBDfDDDfC.DDD.DDBBBf

考题 有如下程序: #includeiostream usingnamespacestd; classBase{ public: Base(intx=O){coutx;} }; classDerived:publicBase{ public: Derived(intx=O){coutx;}private: Baseval; }; intmain(){ Derivedd(1); return0; } 程序执行后的输出结果是( )。A.100B.000C.010D.001

考题 下面程序的运行结果是( )。 #includeiostream.h classbase{ protected: inta; public: base(){cout"0";} }; classbasel:virtualbase{ public: basel(){cout"1";} }; classbase2:virtualbase{ public: base2(){cout"2";} }; classderived:publicbasel,publicbase2{ public: derived(){cout"3";} }; voidmain() { derivedobj; eoutendl: }A.0123B.3120C.O312D.3012

考题 有如下程序: #include<iostream) using namespace std; classBase{ public: Base(int x=0){cout<<x;} }; Class Derived:public Base{ public: Derived(int x=0){cout<<x;} private: Base Val; }; int main(){ Derived d(1); returnA.100B.000C.010D.001

考题 若有以下程序:includeusingnamespacestd;classBase{public: Base() {x=0; } intx;}; 若有以下程序: #include <iostream> using namespace std; class Base { public: Base() { x=0; } int x; }; class Derivedl : virtual public Base { public: Derivedl() { x=10; } }; class Derived2 : virtual public Base { public: Derived2() { x=20; } }; class Derived : public Derivedl,protected Derived2 { }; int main () { Derived obj; cout<<obj.x<<end1; return 0; } 该程序运行后的输出结果是( )。A.10B.20C.30D.0

考题 有如下程序includeusing namespace std;class Base{protected:Base(){cout 有如下程序 #include<iostream> using namespace std; class Base{ protected: Base(){cout<<'A';} Base(char c){cout<<c;) }; class Derived: public Base{ public: Derived(char c){cout<<c;) }; int main(){ Derived dl('B'); return 0; } 执行这个程序屏幕上将显示输出( )。A.BB.BAC.ABD.BB

考题 有如下程序:#includeiostreamUsingnamespacestd;classBase{public:Base(intx=O):valB(x){coutvalB;)~Base( ){coutvalB;)Private:intvalB:};classDerived:publicBase{public:Derived(intX=0,inty=0):Base(x),valD(y)(coutvalD;)~Derived( ){coutvalD;)private:intvalD;};intmain( ){Derivedobj12(2,3);return0;}运行时的输出结果是( )。A.2332B.2323C.3232D.3223

考题 下面程序的输出结果是( )。 #includeiostream Usingnamespacestd; ClassBase{ public: Base(intx=O){countx; } }; ClassDerived:publicBase{ public:Derved(intx=0{countx; } private; Baseval; }; intmina(){ Derivedd(1); retrun0; }A.0B.1C.01D.001

考题 有如下程序: #includeiostream 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;

考题 有以下程序:inClUdeusingnamespacestd;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.1B.5C.2D.0

考题 有如下程序:includeusing namespace std;class BASE{public:~BASE(){cout 有如下程序: #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.BASEB.DERIVEDC.BASEDERIVEDD.DERIVEDBASE