网友您好, 请在下方输入框内输入要搜索的题目:
题目内容
(请给出正确答案)
已知如下类定义: class Base { public Base (){ //... } public Base ( int m ){ //... } protected void fun( int n ){ //... } } public class Child extends Base{ // member methods } 如下哪句可以正确地加入子类中?()
A.private void fun( int n ){ //...}
B.void fun ( int n ){ //... }
C.protected void fun ( int n ) { //... }
D.public void fun ( int n ) { //... }
参考答案
更多 “ 已知如下类定义: class Base { public Base (){ //... } public Base ( int m ){ //... } protected void fun( int n ){ //... } } public class Child extends Base{ // member methods } 如下哪句可以正确地加入子类中?() A.private void fun( int n ){ //...}B.void fun ( int n ){ //... }C.protected void fun ( int n ) { //... }D.public void fun ( int n ) { //... } ” 相关考题
考题
在声明派生类时,如果不显式地给出继承方式,缺省的类继承方式是私有继承 private。已知有如下类定义:class Base{protected:void fun(){}};Class Derived: Base{};则Base 类中的成员函数fun(),在Derived 类中的访问权限是 [12] (注意:要求填写private、protected 或public 中的一项)。
考题
有如下程序:#include +using namespace std ;#includeusing namespace std;class Base{public:void fun(){cout"Base::fun"};class Derived:public Base{public:void fun(){cout"Derived::fun"}};int main(){Derived d;d.fun();return 0;}已知其执行后的输出结果为:Base::funDerived::fun则程序中下划线处应填入的语句是A . Base.fun();B . Base::fun()C . Base-fun()D . fun();
考题
( 12 )在声明派生类时,如果不显式地给出继承方式,缺省的类继承方式是私有继承 private 。已知有如下类定义:class Base {protected:void fun( ) {}};class Derived : Base { };则 Bas e 类中的成员函 数 fun() , 在 Derive d 类中的访问权限是 【 12 】 ( 注意要求填 写private 、 protecte d或 public 中的一项 )。
考题
有如下程序:include using namespace std;class Base{ public: void fun() { cout
有如下程序: #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();
考题
在下列横线处应添加的语句是( )。 class Base{public:void fun(){cout<<"Base::fun"<<end1;}}; class: Derived: public Base { public: void fun() { ______//显示调用基类的fun函数 cout<<"Derived::fun"<<end1; } };A.Derived::funB.Base::fun();C.Pubic::funD.fun();
考题
下面程序的输出结果是【】。include using namespace std; class base { protected: int
下面程序的输出结果是【 】。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;}
考题
有如下程序:include using namespace std;class Base{public:void fun() {cout
有如下程序:#include <iostream>using namespace std;class Base { public: void fun() {cout<<"Base:: fun"<<end1; }};class Derived: public Base ( public: void fun() { ____________________________ cout<<"Derived:: fun"<<end1; }};int main() { Derived d; D. fun(); return O;}已知其执行后的输出结果为:Base:: funDerived:: fun则程序中下划线处应填入的语句是( )。A.Base. fun ();B.Base:: fun ();C.Base->fun();D.fun()
考题
有如下程序:includeincludeusing namespace std;class BASE{char c;public
有如下程序: #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.XYB.YXC.XD.Y
考题
有如下程序: include using namespace std; class Base { public:
有如下程序: #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();
考题
有如下程序: #includeiostream using namespace std; classBase{ public: void fun{ __________________ cout”Base::fun”endl;} }; class Derived:public Base{ public: voidfun{ cout”Derived::fun”endl: } }; int main{ Derived d; A fun; return 0; } 已知其执行后的输出结果为: Base::fun Derived::fun 则程序中下画线处应填入的语句是( )。A. Base.fun;B.Base::fun;C.Base—fun;D.fun;
热门标签
最新试卷