填空题
写出下列程序的执行结果是:__________________。#include using namespace std;class T{ public : T() { a = 0; b = 0; c = 0; } T( int i, int j, int k ) { a = i; b =j; c = k; } void get( int &i, int &j, int &k ) { i = a; j = b; k = c; } T operator* ( T obj );private: int a , b , c;};T T::operator* ( T obj ){ T tempobj; tempobj.a = a * obj.a; tempobj.b = b * obj.b; tempobj.c = c * obj.c; return tempobj;}void main(){ T obj1( 1,2,3 ), obj2( 5,5,5 ), obj3; int a , b , c; obj3 = obj1 * obj2; obj3.get( a, b, c ); cout<<"(obj1*obj2):"<<"a="<
填空题
有如下程序:#includeusing 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).getPay()<
套餐购买该问题答案仅对会员开放,欢迎开通会员 ¥ 19.9
0.64/天
1个月(不限次)
¥ 19.9
1000次
(不限时)
¥ 29.9
0.32/天
3个月(不限次)
¥ 59.9
0.16/天
1年(不限次)
立即支付