[单选题]

有如下类的声明: class Base{ protected: int amount; public: Base(int n=0):amount(n){} int getAmount()const{return amount;} }; class Derived:public Base{ protected: int value public: Derived(int m,int n):value(m),Base(n){} int getData()const{return value+amount;} };已知x是一个Derived对象,则下列表达式中正确的是

A.x. value+x. getAmount()

B.x. getData()-x. getAmount()

C.x. getData()-x. amount

D.x. value+x. amount

参考答案与解析:

相关试题

有如下类声明:class Base{protected:int amount;p

[单选题]有如下类声明: class Base{ protected: int amount; public: Base(int n=0):araount(n){ } int getAmount( )const{retum amount;} }; class Derived:public Base{ protected; int value; public: Derived(int m,int n):value(n1),Base(n){ } int getData( )const{return value

  • 查看答案
  • 有如下程序:#includeclass Base{protected:int i

    [单选题]有如下程序:includeclass Base{protected:int i;public:int j;};class Derived:pub有如下程序: #include<iostream.h> class Base { protected:int i; public:int j; }; class Derived:public Base { int m; public:int n; }; int main() { Derived d; d.i=0; //[1]d.j=0; //[2]d.m

  • 查看答案
  • 有如下类声明:class MyClass{int i;private: int

    [试题]有如下类声明:class MyClass{int i;private: int j;protected:int k;public:int m, n;};其中,私有成员的数量为 ( 9 ) 。

  • 查看答案
  • 有如下类声明:class TestClassint i;private:int

    [单选题]有如下类声明: class TestClass int i; private:int j; protected:int k; public:int m,n; 其中,私有成员的数量为( )。A.0B.1C.2D.3

  • 查看答案
  • 有如下类声明: class XA { int x; public: XA(int

    [单选题]有如下类声明: class XA { int x; public: XA(int n){x=n;} }; class XB:public XA { int y; public: XB(int a,int b); }; 在构造函数XB的下列定义中,正确的是A.XB::XB(int a,int b):x(a),y(b){}B.XB::XB(int a,int b):XA(a),y(b){}C.XB::XB(int a,int b):x(a),XB(b){}D.XB::XB(int a,int b):

  • 查看答案
  • 有如下类声明: class XA{ int x; public: XA(int

    [单选题]有如下类声明:class XA{int x;public:XA(int U)}x=n;}};class XB:public XA{int y;public:XB(int a,int B) ;};在构造函数XB的下列定义中,正确的是A.XB::XB(int a,int B) :x(A) ,y(B) {}B.XB::xB(int a,int B) :XA(A) ,y(B) {}C.XB::XB(int a,int B) :x(A) ,XB(B) {}D.XB::XB(int a,int B) :XA

  • 查看答案
  • 有如下类声明:class XA {int x;public:XA(int n)

    [单选题]有如下类声明: class XA { int x; public: XA(int n) {x=n;} }; class XB: public XA{ int y; public: XB(int a,int b); };在构造函数XB的下列定义中,正确的是______。A.XB:: XB(int a, int b):x(a),y(b) { }B.XB::XB(int a, int b):XA(a),y(b){}C.XB::XB(int a,int b):x(a),XB(b)i}D.XB::XB(i

  • 查看答案
  • 有如下类声明: class XA{int x; public: XA(int n

    [单选题]有如下类声明:class XA{int x;public:XA(int n){x=n;}};class XB:public XA{int y;public:XB(int a, int b) ;};在构造函数XB的下列定义中,正确的是A.XB::XB(int a,int B) :x(A) ,y(B) {}B.XB::XB(int a,int B) :XA(A) ,y(B) {}C.XB::XB(int a,int B) :x(A) ,XB(B) {}D.XB::XB(int a,int B) :X

  • 查看答案
  • 有如下类声明:class SAMPLE{int n;public:SAMPLE

    [单选题]有如下类声明:class SAMPLE{int n;public:SAMPLE (int i = 0): n(i){}void setvalue(int n0);};下列关于 setvalue 成员函数的实现中,正确的是A. . SAMPLE::setvalue(int n0){n = n0;}B. . void SAMPLE::setvalue(int n0){n = n0;}C. . void setvalue(int n0){n = n0;}D. . setvalue(int n0){n

  • 查看答案
  • 有如下类声明: 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 Base{ protected: int amou