单项选择题
在公有继承的情况下,允许派生类直接访问的基类成员包括______。
A.公有成员
B.公有成员和保护成员
C.公有成员、保护成员和私有成员
D.保护成员
点击查看答案&解析
<上一题
目录
下一题>
热门
试题
单项选择题
有如下程序:#include<iostream>using namespace std;class Base{private:void fun1() const{cout<< fun1 ;}protected:void fun2() const{cout<< fun2 ;}public:void fun3() const{cout<< fun3 ;}};class Derived:protected Base{public:void fun4() const{cout<< fun4 ;}};int main(){Derived obj;obj.fun1(); ① obj.fun2(); ②obj.fun3(); ③obj.fun4(); ④return 0;}其中有语法错误的语句是______。
A.①②③④
B.①②③
C.②③④
D.①④
点击查看答案&解析
单项选择题
有如下程序:#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::funDerived::fun则程序中下划线处应填入的语句是______。
A.Base.fun();
B.Base::fun();
C.Base->fun();
D.fun();
点击查看答案&解析
相关试题
有如下类定义:class AA{int a;public...
生成派生类对象时,派生类构造函数调用基类...
有如下程序:#include<iostream>using ...
有如下程序:#include<iostream>using ...
有如下程序: #include<iostream>using...