为完成下面的程序,应在划线处填入的语句是( )。 #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);}
第1题:
有如下程序: #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();
第2题:
请在如下程序中的空格处填写正确的语句:
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;
}
};
第3题:
在下面横线上填上适当的语句,完成程序。
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
第4题:
下列程序中划线处正确的语句是( )。#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();
第5题:
请在下列程序的横线处填写正确的语句。
include<iostream>
using namespace std;
class Base{
public:
void fun(){cout<<"Base fun"<<endl;}
};
class Derivde:public Base{
public:
void fun(){
______∥ 调用基类的函数