有如下类声明: class Base{ protected: int amount; public: Base(int n=0):amount(n){} int getAmountconst{retum amount;} }; class Derived:public Base{ protected: int value; public: Derived(int m,int n):value(m),Base(n){} int getDataconst{return value+amount;} }: 已知x是一个Derived对象,则下列表达式中正确的是( )。A.x.value+X.getAmountB.x.getData一x.getAmountC.x.getData一x.amountD.x.value+X.amount

有如下类声明: class Base{ protected: int amount; public: Base(int n=0):amount(n){} int getAmountconst{retum amount;} }; class Derived:public Base{ protected: int value; public: Derived(int m,int n):value(m),Base(n){} int getDataconst{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; 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+amount;} }; 已知x是一个Derived对象,则下列表达式中正确的是A.x.value+x.getAmount( )B.x.getData( )-x.getAmount( )C.x.getData( )-x.amountD.x.value+x.amount

有如下程序:includeusing namespace std;class Amount{int amount;public:Amount(int 有如下程序: #include<iostream> using namespace std; class Amount{ int amount; public: Amount(int n=0):amount(n){ } int getAmount( )const{return amount;} Amountoperator+=(Amount A) { amount+=a.amount; return; } }; int main( ){ Amount x(3),y(7); x+=y: cout<<x.getAmount( )<<endl; return 0; } 已知程序的运行结果是10,则下画线处缺失的表达式是A.*thisB.thisC.amountD.amount

有以下程序:include using namespace std; class Base { public: Base() { K=0; } int 有以下程序:include<iostream>using namespace std;class Base{public:Base(){K=0;}int x;};class Derivedl:virtual public Base{public:Derivedl(){x=10;}};class Derived2:virtua1 public Base

下面程序的输出结果是【】。include using namespace std; class base { protected: int 下面程序的输出结果是【 】。include <iostream>using namespace std;class base{protected:int a;public:base(){cout<<"0":}};class basel: virtual public base{public:base1(){ cout<<"1";}};class base2 : virtual public base{public:base2(){cout<<"2";}};class derived : public base1,public base2{public:derived () {cout<<"3"; }}int main (){derived obj;cout<<end1;return 0;}

有如下类的声明: 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. amountD.x. value+x. amount

有如下程序: include using namespace std; class Amount{ int amount 有如下程序: #include<iostream> using namespace std; class Amount{ int amount; public: Amount(int n=0):amount(n){} int getAmount()const{return amount;} Amountoperator9=(Amount a){ amount+=a. amount; return______; } }; int main(){ Amount x(3),y(7); x+=y, cout<<x. getAmount()<<endl; return 0; }已知程序的运行结果是10,则下划线处缺失的表达式是A.* thisB.thisC.amountD.amount

有如下程序:include using namespace std;class Base{private:charc;public:Base(cha 有如下程序:#include <iostream>using namespace std;class Base{private: char c;public: Base(char n) :c(n){} ~Base() { cout<<c; } };class Derived: public Base{private: char c; public: Derived(char n):Base(n+1),c(n) {} ~Derived() { cout<<c; }};int main (){ Derived obj ('x'); return 0;}执行上面的程序净输出A.xyB.yxC.xD.y

有下列程序:includeUsing namespace std;Class Amount{ int amount;public; Amount(i 有下列程序: #include<iostream> Using namespace std; Class Amount{ int amount; public; Amount(int n=O):amount(n){} Int getAmount()const{return amount;} Amount operator+=(AmountA) {A.*thisB.thisC.amountD.amount

有如下程序:include using namespace std;class Base{private:char c;public:Base(ch 有如下程序:#include <iostream>using namespace std;class Base{private: char c;public: Base(char n):c(n){} ~Base() { cout<<c; }};class Derived: public Base{private: char c;public: Derived(char n):Base(n+1),c(n){} ~Derived() { cout<<c; }};int main(){ Derived obj('x'); return 0; }执行上面的程序将输出( )。A.xyB.yxC.xD.y