有如下程序: #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 main
A.BBBfDD
B.BBDfDDDf
C.DD
D.DDBBBf
第1题:
以下程序的执行结果为______。
include<iostream>
using namespace std;
class base
{
public:
virtual void who()
{
cout<<"base class"<<endl;
}
};
class derivel:public base
{
public:
void who()
{
cout<<"d
第2题:
有如下程序: #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.BASE
B.DERIVED
C.BASEDERIVED
D.DERIVEDBASE
第3题:
如下程序的输出是 #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)D
B.BBDfDDDf
C.DD
D.DDBBBf
第4题:
有如下程序: #include<iostream> using namespace std; class Base{ public: void output( ){cout<<l;} virtual void Print( ){cout<<'B';} }; class Derived:public Base{ public: void output( ){cout<<1;} void Print( ){cout<<'D';} }; int main( ){ Base*prt=new Derived; prt->output( ); prt->Print( ); delete prt; return 0; } 程序的输出结果是
A.1B
B.1D
C.2B
D.2D
第5题:
有如下程序: #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.BASE
B.DERIVED
C.BASEDERIVED
D.DERIVEDBASE
第6题:
有如下程序: #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.BASE
B.DERIVED
C.BASEDERIVED
D.DERIVEDBASE
第7题:
执行如下程序将输出( ): #include<iostream> using namespace std; class Base { public: Base(){cout<<"BB";fun();} void fun (){tout<<"Brim";} }; class Derived:public Base { public: Derived(){cout<<"DD";} void fun (){cout<<"Dfun";} }; int main(){Derived d;return 0;}
A.DD
B.BBDfunDDDfun
C.BBBfunDD
D.DDBBBfun
第8题:
有如下程序: #include<iostream>#include<iosream> using namespace std; class BASE{ char c; public; BASE(char n):c(n){} virtual ~ BASE(){cout<<c;} }; class DERIVED; public BASE{ char c; public: DERIVED (char n): BASE (n+1)
A.XY
B.YX
C.X
D.Y
第9题:
有如下程序:#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.xy
B.yx
C.x
D.y
第10题:
有如下程序:#nclude <iostream>using namespace std;class Base{ public:void fun1() {cout << "Base\n"; }virtual void fun2() {cout << "Base\n"; }};class Derived: public Base{ public:void fun1() {cout << "Derived\n"; }void fun2() {cout << "Derived\n"; }} void f(Base& b) { B. fun1(); B. fun2(); }int main(){Derived obj;f(obj);return 0;}
A.Base Base
B.Base Derived
C.Derived Base
D.Derived Derived
第11题:
有如下程序: #include<iostream> using namespace std; class Base{ public: virtual void func1(){cout<<"Base 1";} void rune2(){cout<<"Base 2";} }; class Derived:public Base{ public: void func1(){cout<<"Derived 1";} void func2(){cout<<"Derived 2";} }; int main(){ Base *p=new Derived; P->func1(); P->func2(); return 0: } 运行此程序,屏幕上将显示输出______。
A.Derived 1 Base 2
B.Base 1 Base 2
C.Derived 1 Derived 2
D.Base 1 Derived 2
第12题:
请在如下程序中的空格处填写正确的语句:
include <iostream>
using namespace std;
class Base {
public:
void fun() {cout<<"Base fun"<<endl; }
};
class Derived: public Base {
public:
void fun() {
【 】; //调用基类的函数fun()
cout<<"Derived fun "<<endl;
}
};
第13题:
有如下程序:#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.BBBfDD
B.BBDfDDDf
C.DD
D.DDBBBf
第14题:
有如下程序: #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.Derived
B.DerivedBase
C.BaseDerived
D.DerivedDerived
第15题:
有如下程序: #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.0
B.1
C.01
D.001
第16题:
有如下程序: #include <iostream.h> using namespace std; class Base { public: Base(){ cout<<"BB"; f(); } voidf(){cout <<"Bf"; } }; class Derived: public Base { public: Derived (){cout<<"DD";} void f(){cout<<"Df";} }; int main(){Derived d; return 0;} 执行上面的程序将输出
A.BBBfDD
B.BBDfDDDf
C.DD
D.DDBBBf
第17题:
有如下程序: #include <iostream> using namespace std; class Base { public: void fun() { cout<<"Base::fun"<<endl; } }; class Derived : public Base { public: void fun() { ______ cout<<"Derived::fun"<<endl; } }; int main() { Derived d; d.fun(); return 0; } 已知其执行后的输出结果为: Base::fun Derived::fun 则程序中下划线处应填入的语句是( )。
A.Base.fun();
B.Base::fun();
C.Base->fun();
D.fun();
第18题:
下面程序的输出结果是【 】。
include <iostream>
using namespace std;
class base
{
protected:
int a;
public:
base(){cout<<"0":}
};
class basel: virtual public base
{
public:
base1(){ cout<<"1";}
};
class base2 : virtual public base
{
public:
base2(){cout<<"2";}
};
class derived : public base1,public base2
{
public:
derived () {cout<<"3"; }
}
int main ()
{
derived obj;
cout<<end1;
return 0;
}
第19题:
下列程序的输出结果为2,请将程序补充完整。
include<iostream>
using namespace std;
class Base
{
public:
______void fun(){cout<<1;}
};
class Derived:public Base
{
public:
void fun(){cout<<2;}
};
int main()
{
Base*p=new Derived;
p->fur();
delete p;
return 0;
}
第20题:
有以下程序: #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; p
A.XY
B.YX
C.X
D.Y
第21题:
有下列程序: #include<iosteram.h> using namespace std; class Base { public: Base(){cout<<"BB"; f(); } void f(){cout<<"Bf";} }; class Derived:public Base { public: Derived(){cout<<"D
A.BBBfDD
B.BBDfDDDf
C.DD
D.DDBBBf
第22题:
有如下程序 #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.B
B.BA
C.AB
D.BB
第23题:
有如下程序: #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.BASE
B.DERIVED
C.BASEDERIVED
D.DERIVEDBASE