如下程序的输出结果是______。
include<iostream>
using namespace std;
class Wages{ //“工资”类
double base; //基本工资
double bonus; //奖金
double tax; //税金
public:
Wages(double CBase,double CBonus,doable CTax):
base(CBase),bonus(CBonus),tax(CTax){ }
double getPay( )const; //返回应付工资额
Wages operator+(Wages w)cons[; //重载加法
};
double Wages::getPay( )cons[{return base+bonus-tax;}
Wages Wages::operator+(Wages w)const{return Wages(base+w.base,bonus+w.bonus,tax+w.tax);}
int main( ){
Wages wl(2000,500,100),w2(5000,1000,300);
eout<<(wl+w2).getPay( )<<endl;
return 0;
}
第1题:
有如下程序: #include<iostream> void fun(int&x,int y){int t=x;x=y;y=t;} int main() { int a[2]={23,42}; fun(a[1],a[0]; std::cout<<a[0]<<","<<a[1]<<std::ndl; return 0; } 执行后的输出结果是
A.42,42
B.23,23
C.23,42
D.42,23
第2题:
如下程序的输出结果是 #include<iostream> void fun(int & X,inty){intt=x;x=y;y=t;} int main( ){ int a[2]={23,42}; fun(a[1],a[0]); std::cout<<a[0]<<","<<a[1]<<std::endl; return 0; }
A.42,42
B.23,23
C.23,42
D.42,23
第3题:
请将如下程序补充完整,使得输出结果为:bbaa。
include<iostream>
using naluespace std;
class A{
public:
______{eout<<"aa";}
};
class B:public A{
public:
~B( ){eont<<"bb";}
};
int ulain( ){
B*P=new B;
delete P;
return 0;
}
第4题:
有如下程序: #include <iostream> void fun(int& x, int y){int t=x;x=y;y=t;} int main () { int a[2]={23,42}; fun(a[1],a[0]); std::cout<<a[0]<<","<<a[1]<<std::endl; return 0; } 执行后的输出结果是
A.42,42
B.23,23
C.23,42
D.42,23
第5题:
有如下程序:
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;
}
程序的输出结果是