[单选题]

有如下类定义: class MyBase { int k; public: MyBase(int n=0):k(n) { } int value( )const{ return k;} }; class MyDerived: MyBase { intj; public: MyDerived(int i): j(i) {} int getK( )const{ return k; } int getJ( )const{ return j; } }; 编译时发现有一处语法错误,对这个错误最准确的描述是

A.函数getK试图访问基类的私有成员变量k

B.在类MyDerived的定义中,基类名MyBase前缺少关键字public、protected或private

C.类MyDerived缺少一个无参的构造函数

D.类MyDerived的构造函数没有对基类数据成员k进行初始化

参考答案与解析:

相关试题

有如下类定义:class MyBase{int k;public:MyBase(

[单选题]有如下类定义: class MyBase{ int k; public: MyBase(int n=0):k(n){} int value( )const{return k;} }; class MyDerived:MyBase{ int j; public: MyDerived(int i):j(i){} int getK( )eonst{return k;} int getJ( )const{return j;} }; 编译时发现有一处语法错误,对这个错误最准确的描述是A.函数getK试图访

  • 查看答案
  • ( 31 ) 有如下类定义 :class MyBase{int k;public

    [单选题]( 31 ) 有如下类定义 :class MyBase{int k;public:MyBase(int n=0):k(n){ }int value( )const{ return k;}};class MyDerived: MyBase{int j;public:MyDerived(int i): j(i) {}int getK( )const{ return k; }int getJ( )const{ return j; }};编译时发现有一处语法错误 , 对这个错误最准确的描述是A. )函数

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

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

  • 查看答案
  • 有如下类声明: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中

  • 查看答案
  • 有如下类声明: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 se

    [单选题]有如下类声明: 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中保护

  • 查看答案
  • 有如下类声明: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 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. int j; public: void set(int m,int n){MyBASE::set(m);j=n;} int get()const{return MyBASE::get()+j;} }; 则类MyDERIVED中保

  • 查看答案
  • 有如下类定义:ClaSS MyClass{int value;public:My

    [单选题]有如下类定义: ClaSS MyClass{ int value; public: MyClass(int n):value(n){ } int getValue( )const{return value;} l; 则类MyClass的构造函数的个数是A.1个B.2个C.3个D.4个

  • 查看答案
  • 有如下类定义:class AA{int a;public:int getRef(

    [单选题]有如下类定义:class AA{int a;public:int getRef() const{return &a;} // ①int getvalue() const{return a;} // ②void set(int n) const{a=n;} // ③friend void show(AA aa) const {cout< // ④};其中的四个函数定义中正确的是A. . ①B. . ②C. . ③D. . ④

  • 查看答案
  • 有如下类定义: class MyBase { int k; public: My