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

题目内容 (请给出正确答案)
有以下程序: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.1

B.5

C.2

D.0


参考答案

更多 “ 有以下程序: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 ” 相关考题
考题 有如下程序: include using namespace std; class Base { public: 有如下程序: #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.1D.1

考题 有如下程序: #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: vir 以下程序的执行结果为______。include<iostream>using namespace std;class base{public:virtual void who(){cout<<"base class"<<endl;}};class derivel:public base{public:void who(){cout<<"d

考题 有以下程序:include using namespace std; class Base { public: Base() { K=0; } int 有以下程序:include<iostream>using namespace std;class Base{public:Base(){K=0;}int x;};class Derivedl:virtual public Base{public:Derivedl(){x=10;}};class Derived2:virtua1 public Base

考题 若有以下程序:include using namespace std;class Base{public: Base ( ) {x=0; } in 若有以下程序: #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.20B.30C.10D.0

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

考题 下列程序的运行结果是______。include class Base { public: void f(int x){cout 下列程序的运行结果是______。include<iostream.h>class Base{public:void f(int x){cout<<“Base:”<<x<<endl;});class Derived:public Base{public:void f(char*str){cout<<“Derived:”<<str<<endl;}};void main(void){Base*pd=ne

考题 有以下程序 include using namespace std; class Base { int a; public: Base(int x) 有以下程序include <iostream>using namespace std;class Base{int a;public:Base(int x){ a=x; }void show(){ cout<<a; }class Derived : public Base{int b;public:Derived(int i) :Base(i+1),b(i){}void show() { cout<<b;};int main (){Base b(5),*pb;Derived d(1);pb=d;pb->show ();return 0;}运行后的打印结果是______。

考题 在下列程序画线处填入的正确语句是()。includeusing namespace std;classBase{public: 在下列程序画线处填入的正确语句是( )。 #include <iostream> using namespace std; class Base { public: void fun() { cout<<"Base::fun",<<end1; } }; class Derived:public Base { void fun() { ______________ //显式调A.fun();B.Base.fun();C.Base::fun();D.Base->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

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

考题 有以下程序: include class A { intx; public: A(int a) { x=a;} friend class B; 有以下程序: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) ;}程序执行后的输出结果是【 】。

考题 有以下程序:include include using namespace std;class base{private: cha 有以下程序: #include <iostream> #include <string> using namespace std; class base { private: char baseName[10]; public: base ( ) { strcpy (baseName, "Base"); } virtual char *myName() {A.DerivedBaseB.BaseBaseC.DerivedDerivedD.BaseDerived

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

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

考题 有以下程序:includeusing namespace std;class BASE{private: char c;public: BASE(c 有以下程序: #include <iostream> using namespace std; class BASE { private: char c; public: BASE(char n):c(n);{} virtual~BASE() { cout<<c; } }; class DERIVED:public BASE { char c; pA.XYB.YXC.XD.Y

考题 有以下程序include using namespace std:class Base{private:char c;public:Base(cha 有以下程序#include <iostream>using namespace std:class Base{private: char c;public: Base(char n) :c(n) {} ~Base ( ) { cout<<c; }}; class Derived : public Base{private: char c;public: Derived(char n):Base (n+1),c(n) {} ~Derived() { cout<<c; }};int main(){ Derived obj('x'); return 0;} 执行后的输出结果是A.xyB.yxC.xD.y

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

考题 有以下程序: #include(iostream) usingnamespacestd; intmain( ) { intx=15: while(x10&&x50) { x++; if(x/3) { x++;break; }} coutxendl; return0; } 执行后的输出结果是( )。A.15B.16C.17D.18

考题 有下列程序: include using namespace std; classBase { protected: int i; public 有下列程序: #include<iostream.h> using namespace std; classBase { protected: int i; public: int j; }; classDerived:public Base { int m; public: intn; }; intA.[1]和[2]B.[1)和[3]C.[2]和[3]D.[2]和[4]

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

考题 有如下程序: #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{pr 为完成下面的程序,应在划线处填入的语句是( )。 #include <iostream> using namespace std; class Base { private: int x; public: Base(int i) { x=i; } ~Base(){} }; class Derived : public Base { public: _______________ //完成类Derive构造函数的定义 }; int main() { Derived Obj; return 0; }A.Derived(int i):Base(i){}B.Derived(){}C.voidDerived(int i):Base(0){}D.Derived(int i){Base(i);}

考题 若有以下程序: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{public:Base(){x=0;}int x;};c 若有以下程序: #include<iostream> using namespace Std; Class Base {public: Base() {x=0;} int x;}; class Derivedl:virtua1 public Base {public: Derived1() {x=10;}}; class Derived2:virtual1 public Base {public: Derived2()A.20B.30C.10D.0

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