[单选题]

有如下类定义:

class B{

public: void fun1(){}

private: void fun2(){}

protected: void fun3(){}

};

class D: public B{

protected: void fun4(){}

};

若obj是类D的对象,则下列语句中不违反访问控制权限的是( )。

A.) obj. fun1();

B.) obj. fun2();

C.) obj. fun3();

D.) obj. fun4();

A.

B.

C.

D.

参考答案与解析:

相关试题

若有如下类定义: class B { void fun1() { protect

[单选题]若有如下类定义: class B { void fun1() { protected: double var1; public: void fun2() { }, class D: public B protected: void fun3() { };已知obj是类D的对象,下列语句中不违反类成员访问控制权限的是A.obj.fun1();B.obj.varl;C.obj.fun2();D.obj.fun3();

  • 查看答案
  • ( 31 )若有如下类定义 :class B{void fun1(){}prot

    [单选题]( 31 )若有如下类定义 :class B{void fun1(){}protected:double varl;public:void fun2(){}};class D:public B{protected:void fun3(){}};已知 obj 是类 D 的对象,下列句中不违反类成员访问控制权限的是A. ) obj.funl();B. ) obj.varl;C. ) obj.fun2();D. ) obj.fun3();

  • 查看答案
  • 若有如下类定义:class B{void fun1( ){}private:do

    [单选题]若有如下类定义: class B{ void fun1( ){} private: double varl; public: void fun2( ){ } }; class D:public B{ private: void fun3( ){ } }; 已知obj是类D的对象,下列语句中不违反类成员访问控制权限的是A.obj.fun1( );B.obj.varl;C.obj.fun2( );D.obj.fun3( );

  • 查看答案
  • 有如下类定义:class Fun{public:Fun(int v):value

    [单选题]有如下类定义: class Fun { public: Fun(int v):value(v){}//① ~Fun(){}//② private: Fun{},//③ int value=0;//④ }; 其中存在语法错误的行是( )。A.①B.②C.③D.④

  • 查看答案
  • 请将下列类定义补充完整。class Base{public:void fun()

    [单选题]请将下列类定义补充完整。class Base{public:void fun(){tout<<"Base::fun"<<endl;}};class Derived:public Base{public:void fun(){______//显示调用基类的fun函数cout<<"Derived::fun"<<endl;};

  • 查看答案
  • 若有如下类定义:class B{ void funl(){}protected:

    [单选题]若有如下类定义: class B{ void funl(){} protected: double varl: public: void fun2(){} }; class D:public B{ protected: void fun3(){} }; 已知obj是类D的对象,下列语句中不违反类成员访问控制权限的是( )。A.obj.funl();B.obj.varl;C.obj.fun2();D.obj.fun3();

  • 查看答案
  • 有如下类声明:class MyBASE{ int k: public; void

    [单选题]有如下类声明: class MyBASE { int k: public; void set(int n){k=n;} int get() const{return k;} }; class MyDERIVED: protected MyBASE { protected: int j; public: void set(int m, int n){MyBASE::set(m);j=n;} int get() const{return MyBASE::get()+j;} }; 则类MyDERIVE

  • 查看答案
  • 有如下类声明:class MyBASE{ int k;public: void

    [单选题]有如下类声明: class MyBASE { int k; public: void set(int n){k=n;} int get()const{return k;} }; class MyDERIVED:protected MyBASE { protected: int j; public: void set(int m, int n) {MyBASE::set(m);j=n;} int get()const{return MyBASE::get()+j;} }; 则类MyDERIVED中

  • 查看答案
  • 有如下程序public class Sun{public static void

    [单选题]有如下程序 public class Sun { public static void main(String args[ ]) { int x=1,a=0,b=0; switch(x) { case 0:b++; case 1:a++; case 2: a++; b++; } System.out.println("a="+a+","+"b="+B) } }该程序的输出结果是( )。A.a=2,b=1B.a=1,b=1C.a=1,b=0D.a=0,b=0

  • 查看答案
  • 有如下类声明:class MyBASE{int k;public:void se

    [单选题]有如下类声明: class MyBASE{ int k; public: void set(int n){k=n;} int get( )const{return k;} }; class MyDERIVED:protected MyBASE{ protected: intj; public: void set(int m,int n){MyBASE::set(m);j=n;} int get( )const{return MyBASE::get( )+j;} }; 则类MyDERIVED中保护

  • 查看答案
  • 有如下类定义: class B{ public: void fun1(){} p