网友您好, 请在下方输入框内输入要搜索的题目:
有如下程序:
include<iostream>
using namespace std;
class Wages{ //“工资”类
double base; //基本工资
double bonus; //奖金
double tax; //税金
public:
Wages(double CBase,double CBonus,double CTax):
base(CBase),bonus(CBonus),tax(CTax){}
double getPay()const; //返回应付工资额
Wages operator+(Wages w)const; //重载加法
};
double Wages::getPay()const{return base+bonus-tax;}
Wages Wages::operator+(Wages W)const{
return Wages(base+w.base,bonus+w.bonus,tax+w.tax);
}
int main(){
Wages w1(2000,500,100),w2(5000,1000,300);
cout<<(w1+w2).getPay0<<end1;
return 0;
}
程序的输出结果是
参考答案