有如下类定义: classB{ public:voidfunl(){} privace:voidfun2(){} protected:voidfun3(){} }; classD:publicB{ protected:voidfun4(){} }; 若obj是类D的对象,则下列语句中不违反访问控制权限的是( )。A.obj.fun1();B.obj.fun2();C.obj.fun3();D.obj.fun4();
有如下类定义: classB{ public:voidfunl(){} privace:voidfun2(){} protected:voidfun3(){} }; classD:publicB{ protected:voidfun4(){} }; 若obj是类D的对象,则下列语句中不违反访问控制权限的是( )。
A.obj.fun1();
B.obj.fun2();
C.obj.fun3();
D.obj.fun4();
相关考题:
有如下程序:#includeusing namespace std;class Base{private:void funl() const{cout"funl";}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.funl(); // ①obj.fun2(); // ②obj.fun3(); // ③obj.fun4(); // ④return 0;}其中有语法错误的语句是A . ①②③④B . ①②③C . ②③④D . ①④
( 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() { 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();
有如下程序: include using namespace std; class B { public: 有如下程序: #include <iostream> using namespace std; class B { public: virtual void show() { cout<<"B"; } }; class D: public B{ public: void show() { cout<<"D"; } }; void fun1(B *ptr) { ptr->show();} void fun2(B ref) { ref. show();} void fun3(B b) {b.show();} int main() { B b,*p=new D; D d; fun1(p); fun2(b); fun3(d); return 0; }程序的输出结果是A.BBBB.BBDC.DBBD.DBD
若有如下类定义: 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( );
有如下程序:includeusing namespace std;class B{public:virtual void show( ){cout 有如下程序: #include<iostream> using namespace std; class B{ public: virtual void show( ){cout<<"B";} }; class D:public B{ public: void show( ){cout<<"D";} }; void funl(B*ptr){ptr->show( );} void fun2(Bref);ref.show( );} void fun3(B b){b.show( );} int nlain( ){ B b,*P=Dew D; D d; funl(p); fun2(b); fun3(d); return 0; } 程序的输出结果是A.BBBB.BBDC.DBBD.DBD
有如下程序: include using namespace std; class Base { private: 有如下程序: #include<iostream> using namespace std; class Base { private: void funl()const {cout<<"funl";} 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.funl(); //① obj.fun2(); //② obj.fun3(); //③ obj.fun4(): //④ return 0; } 其中有语法错误的语句是A.①②③④B.①②③C.②③④D.①④
有如下类定义: class B { public:void funl{} private:void fun2{} protected:void fun3{} }; class D:public B j protected:void fun4{} }; 若obj是类D的对象,则下列语句中不违反访问控制权限的是( )。A.obj.fun1;B.obj.fun2;C.obj.tim3;D.ohj.fun4;
若有如下类定义: 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();