下列程序中划线处正确的语句是( )。#include <iostream>using namespace std;class Base{public:void fun() { cout<<"Base:: fun"<<end1; }};class Derived: public Base{ void fun() { _______________________ //显试调用基类的函数 fun() cout <<"Derived:: fun"<<end1;};
A.fun();
B.Base. fun();
C.Base:: fun();
D.Base->fun();
第1题:
应在下面程序下划线中填写的正确的语句是( )。 #include <iostream> using namespace std; class A{ public: void test(){cout<< "this is A!";} }; class B:public A{ void test(){ ______ //显示调用基类函数test() cout<< "this is B!"; } }; void main(){}
A.A::test()
B.test()
C.B::test()
D.this->test()
第2题:
为完成下面的程序,应在划线处填入的语句是 #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.void Derived (int i):Base(i){}
D.Derived(int i){Base(i);}
第3题:
请在下列程序中的横线处填写正确的语句。
include<iostream>
using namespace std;
class Base{
public:
void fun(){cout<<“Basefun”<<endl;}
);
class Derivde:public Base{
public:
void fun(){
//调用基类的函数fun()
cout<<“Derived fun”<<endl;
}
};
第4题:
有以下程序:
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
第5题:
有如下程序: #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();
第6题:
在下列程序画线处填入的正确语句是( )。 #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();
第7题:
有如下程序: #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
第8题:
应在下列程序画线处填入的正确语句是 ( )。 #include <iostream> using namespace std; clas Base { public: void fun() { cout<<"Base::fun"<<end1; } }; class Derived : public Base { void fun() { ________________//显示调用基类的函数 fun() cout<<"Derived::fun"<<end1; } };
A.fun();
B.Base.fun();
C.Base::fun();
D.Base->fun();
第9题:
有如下程序: #include<iostream> using namespace std; class Base { public: void fun() { cout<<"Base::fun"<<endl; } }; class Derived: public Base { public: void tim() } ____________ cout<<"Derived:: fun"<<endl; } }; int main() { Derived d; d.fun(); return O; } 已知其执行后的输出结果为: Base::fun Derived::fun 则程序中下划线处应填入的语句是
A.Base.fun();
B.Base::fun();
C.Base->fun();
D.fun();
第10题:
有如下程序: #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
第11题:
在下列的程序的横线处填上适当的语句,使该程序的输出为12。
include<iostream.h>
using namespace std;
class Base
{
public:
int a,b;
Base(int i){a=i;}
};
class Derived:public Base
{
int a;
public:
Derived(int x):Base(x),b(x+1){};
void show()
{
第12题:
在下面横线上填上适当的语句,完成程序。
include<iostream>
using namespace std;
class Base
{
int x;
public:
Base(int i){x=i;}
~Base(){}
);
class Derived:public Base
{
public:
______//完成类Derive构造函数的定义
};
iht main()
{
Derived obj
第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 { 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
第15题:
下列程序的输出结果为2,请将程序补充完整。
include<iostream>
using namespace std;
class Basc
{
public:
【 】void fun(){cout<<1;}
};
class Dcrived:public Base
{
public:
void fun(){cout<<2;}
};
int main()
{
Base*p=new Derived;
p->fun();
delete p;
return 0;
}
第16题:
有如下程序: #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
第17题:
有如下程序: #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
第18题:
下列程序的输出结果为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;
}
第19题:
有以下程序: #include <iostream> #include <string> using namespace std; class base { private: char baseName[10]; public: base ( ) { strcpy (baseName, "Base"); } virtual char *myName() {
A.DerivedBase
B.BaseBase
C.DerivedDerived
D.BaseDerived
第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 {
public:
void fun() {cout<<"Base fun"<<endl; }
};
class Derived: public Base {
public:
void fun() {
【 】; //调用基类的函数fun()
cout<<"Derived fun "<<endl;
}
};
第23题:
请在下列程序的横线处填写正确的语句。
include<iostream>
using namespace std;
class Base{
public:
void fun(){cout<<"Base fun"<<endl;}
};
class Derivde:public Base{
public:
void fun(){
______∥ 调用基类的函数