[单选题]

有如下类定义:

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 gutj()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: My

    [单选题]有如下类定义: 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; } }; 编译时发现有一处语法错误,对这个错误最准确的描述是

  • 查看答案
  • 有如下类声明: 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 A{char *a;public:A():*(0){}

    [单选题]有如下类定义:class A{char *a;public:A.():*(0){}A.(char * aA){//把aa所指字符串拷贝到a所指向的存储空间a=________;strcpy(a,aA);}~A(){delete[]a;}};横线处应填写的表达式是A.new char[strlen(aA)+1]B.char[strlen(aA)+1]C.char[strlen(aA)]D.new char[sizeof(aA)-1]

  • 查看答案
  • 有如下类定义:classMyBase{intk;public;MyBase(in