单选题 有如下程序:
#include<iostream>
Using namespace std;
Class Amount{
int amount;
public;
Amount(int n=0):amount(n){}
Int getAmount()const{return amount;}
Amount&operator+=(Amount a){
amount+=a.amount;
return______;
}
};
int main(){
Amount x(3), y(7);
x+=y;
cout<<x.getAmount()<<endl;
return 0;
}
已知程序的运行结果是10,则下画线处缺失的表达式是______。
【正确答案】 D
【答案解析】[解析] Amount &operator+=(Amount a)是+=的重载成员函数,实现的功能是两个对象的数据成员相加,amount存放的是和值。故要返回amount的值。