請使用VC6或使用【答題】菜單打開考生文件夾progl下的工程progl,該工程中包含程序文件main. cpp,其
請使用VC6或使用【答題】菜單打開考生文件夾progl下的工程progl,該工程中包含程序文件main. cpp,其中有Salary(“工資”)類和主函數(shù)main的定義。程序中位于每個“//ERROR ****found****”之后的一行語句行有錯誤,請加以改正。改正后程序的輸出結果應為: 應發(fā)合計:3500應扣合計:67.5實發(fā)工資:3432.5 注意:只修改每個“//ERROR ****found****”下的那一行,不要改動程序中的其他內容。 include<iostream> using namespace std; class Salary{ public: Salary(const char *id,double the_base,double the bonus,double the_tax) //ERROR **********found********** :the_base(base),the_bonus(bonus),the_tax(tax) { staff_id=new char[strlen(id)+1]; strcpy(staff_id,id); } //ERROR **********found********** ~Salary{delete * staff_id;} double getGmssPayconst{retum base+bonus;}//返回應發(fā)項合計 double getNetPayconst}retum getGmssPay-tax;}//返回實發(fā)工資額 private: char * staff id;//職工號 double base;//基本工資 double bonus;//獎金 double tax;//代扣個人所得稅 }; int main{ Salary pay(”888888”,3000.0,500.0,67.50); cout<<”應發(fā)合計:”<<pay.getGrossPay<<" "; cout<<”應扣合計:”<<pay.getGrossPay一pay.getNetPay<<””; //ERROR**********found********** cout<<”實發(fā)工資:”<<pay::getNetPay<<endl; return 0; }
正確答案:(1)base(the—base),bonus(the—bonus),tax(the—tax)(2)Salary{delete[]staff_id;}(3)cout<<”實發(fā)工資:”<<pay.getNetPay<<end1;
詞條內容僅供參考,如果您需要解決具體問題
(尤其在法律、醫(yī)學等領域),建議您咨詢相關領域專業(yè)人士。