搜题
网友您好,请在下方输入框内输入要搜索的题目:
搜题
题目内容 (请给出正确答案)
提问人:网友hfzhujun 发布时间:2022-01-06
[主观题]

请使用VC6或使用【答题】菜单打开考生文件夹progl下的工程progl,该工程中包含程序文件main. cpp,其

中有Salary(“工资”)类和主函数main的定义。程序中位于每个“//ERROR ****found****”之后的一行语句行有错误,请加以改正。改正后程序的输出结果应为: 应发合计:3500应扣合计:67.5实发工资: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;}//返回应发项合计 double getNetPayconst}retum getGmssPay-tax;}//返回实发工资额 private: char * staff id;//职工号 double base;//基本工资 double bonus;//奖金 double tax;//代扣个人所得税 }; int main{ Salary pay(”888888”,3000.0,500.0,67.50); cout<<”应发合计:”<<pay.getGrossPay<<" "; cout<<”应扣合计:”<<pay.getGrossPay一pay.getNetPay<<””; //ERROR**********found********** cout<<”实发工资:”<<pay::getNetPay<<endl; return 0; }

简答题官方参考答案 (由简答题聘请的专业题库老师提供的解答)
查看官方参考答案
更多“请使用VC6或使用【答题】菜单打开考生文件夹progl下的工程progl,该工程中包含程序文件main. cpp,其”相关的问题
第1题
请使用VC6或使用【答题】菜单打开考生文件夹projl下的工程projl,此工程中含有一个源程碍文件 projl
.epp。其中位于每个注释“//ERROR ****found****”之后的一行语句存在错误。请改正这些错误,使程序的输出结果为: ConstruCtor Called. The value is 10 Copy ConstruCtor Called. The value is 10 DestruCtor Called. DestruCtor Called. 注意:只修改注释“//ERROR ****found****”的下一行语句,不要改动程序中的其他内容。 //pwjl.Cpp inClude<iostream> ’using namespaCe std; Class MyClass{ publiC: //ERROR**********found********** MyClass(int i) {value=i;Cout<<”ConstruCtor Called.” <<endl;} //ERROR**********found********** MyClass(eonst MyClass P) { value = P.value; eout<<”Copy ConstruCtor Called.”<<endl; } void Print {Cout<<”The value is” <<value<<endl;} //ERROR**********found********* void-MyClass {Cout<<”DestruCtor Called.”<<endl;} private: int value; }; int main { MyChas objl owl.Print; MyClmss obj2(owl); obj2.Print; retum 0;

点击查看答案
第2题
请使用VC6或使用【答题】菜单打开考生文件夹proj2下的工程proj2,该工程中包含一个程序文件 main.cp
p,其中有类CPolygon(“多边形”)、CRectangle(“矩形”)、CTriangle(“三角形”)的定义。请在横线处填写适当的代码并删除横线,以实现上述类定义。该程序的正确输出结果应为: 注意:只能在横线处填写适当的代码,不要改动程序中的其他内容,也不要删除或移动“//****found****”。 include<lostream> {tout<<——<<endl;} class CRectangle:public CPolygon{ CRe&angle(int w,int h):width(w),height(h){} int area(void){return(width *height);} class CTriangle:public CPolygon{ int length;//三角形一边长 int height;//该边上的高 public: CTriangle(int l,int h):length(1),height(h){} //*********found********* int area(void){return(——)/2;} }; int main{ CRectangle rect(4,5); CTriangle trgl(4,5); //*********found********* ______ *ppolyl,* ppoly2; ppolyl=▭ ppoly2=&trgl; ppolyl->printarea; ppoly2->printarea; retun 0;

点击查看答案
第3题
请使用VC6或使用【答题】菜单打开考生文件夹projl下的工程projl。程序中位于每个“//ERROR****found
料****之后的一行语句有错误,请加以改正。改正后程序的输出结果应为: Name:Smith Age:21 ID:99999 CourseNum:12 Record:970 注意:只修改每个“//ERROR****found****”下的那一行,不要改动程序中的其他内容。 include<iostream> using namespace std; class Studentlnfo { protected: //ERROR********************found**************** char Name; int Age; int ID: int CourseNum; float Record; public: Studentlnfo(char*name,int Age,int ID,int coumeNum,float record); //ERROR ********************found******************** void~Studentlnfo{} float AverageRecord{ return Record/CourseNum; } void showconst{ cout<<”Name:”<<Name<<”Age:”<<Age<<”ID:”<<ID <<”CourseNum:”<<CourseNum<<”Record:”<<Record<<endl; } }; //ERROR ******************found************** StudentInfo StudentInfo(char*Name,int Age,int ID,int CourseNum,float Record) { Name=name; Age=age; this一>ID=ID: CourseNum=courseNum: Record=record; } int main { Studentlnfo st(’’Smith”,21,99999,12,970); st.show; return 0; }

点击查看答案
第4题
请使用【答题】菜单命令或直接用VC6打开考生文件夹下的工程prog3,其中声明了ValArray类,该类在内部
维护一个动态分配的整型数组。ValArray类的复制构造函数应实现对象的深层复制。请编写ValArray类的复制构造函数。在main函数中给出了一组测试数据,此种情况下程序的输出应该是: ValArray vl={1,2,3,4,5} ValArray v2={1,2,3,4,5} 要求: 补充编制的内容写在“//*********333*********”与“//*********666*********”之间,不得修改程序的其他部分。 注意:程序最后将结果输出到文件out.dat中。输出函数write To File已经编译为boj文件,并且在本程序中调用。 //ValArray.h include<iostream> using namespace std; class ValArray{ int *v: int size; public: ValArray(const int * P,int n):size(n) { v=new int[size]; for(int i=0;i<size;i++) v[i]=P[i];

点击查看答案
第5题
清使用VC6或使用【答题】菜单打开考生文件夹projl下的工程projl,此工程中包含了类Pets(“宠物”) 和

清使用VC6或使用【答题】菜单打开考生文件夹projl下的工程projl,此工程中包含了类Pets(“宠物”) 和主函数main的定义。程序中位于每个“//ERROR****found ****”之后的一行语句有错误,请加以改 正。改正后程序的输出结果应为: Name:sonny Type:dog Name:John Type:dog Name:Danny Typc:cat Name:John Type:dog 注意:只修改每个“//ERROR ****found ****”下的那一行,不要改动程序中的其他内容。 include<iostream> using namespace sm; enum Pets_type{d09,cat,bird,fish}; class Pets{ private: char *name; Pets_type type; public: Pets(const char *name=”sonny”,Pets_type type=dog); Pets&operator=(const Pets&s); ~Pets; void showeonst;}; Pets::Pets(eonst char$naIne,Pets_type type) //构造函数 { This ->name=new char[strlen(name)+1]; strcpy(this一>name,name); //ERROR *********found********* type=type; }{ Pets::~Pets//析构函数,释放name所指向的字符串 { //ERROR *********found********* name=’/0‘; } Pets&Pets::0perator=(const Pets&s){ if(&s==this)//确保不要向自身赋值 return *this; delete[]name; name=new char[strlen(S.name)+1];//ERROR *********found********* strcpy(this一>nmne,name); type=S.type: return *this;} void Pets::showconst cout<<“Name:”<<name<<”Type:”: Pets mypetl,mypet2(’’John”,dog);

点击查看答案
第6题
请使用VC6或使用【答题】菜单打开考生文件夹projl下的工程projl,其中有枚举DOGCOLOR、狗类Dog和主函
数main的定义。程序中位于每个“//ERROR ****found****”下的语句行有错误,请加以改正。改正后程序的输出结果应该是: There is a white dog named Hoh0. There is a blaCk dog named Haha. There is a motley dog named Hihi. 注意:只修改每个//ERROR****found****女料下的那一行,不要改动程序中的其他内容。 inClude<iostream> using namespaCe std; //狗的颜色:黑、白、黄、褐、花、其他 enum DOGCOLOR{BLACK,WHITE,YELLOW,BROWN,PIEBALD,OTHER}; Class Dog{//狗类 DOGCOLOR Color; Char name[20]; statiC int Count; publiC: Dog(Char nalTle[],DOGCOLOR Color){ strCpy(this一>name,name); //ERROR**********found**********、 strCpy(this一>Color,Color); } 1 DOGCOLOR getColorConst{retum Color;} //ERROR**********found********** Const Char * 9etNameConst{return*finin9;} Const Char * 9etColorStringConst{ switCh(Color){ Case BLACK:return”blaCk“; Case WHITE:return”white”: Case YELLOW:return’"yellow”: Case BROWN:return”brown”; ease PIEBALD:return”piebald”: } return”motley”; } void showConst{ . Cout<<”There is a”<<getColorString<<”dog named’’<<name<<’.’<<endl; } }; int main{ //ERROR**********found********** Dog dogl(”Hoh0”,WHITE),dog2(”Haha”,BLACK);d0g3(”Hihi”,0THER); d091.show; dos2.show; dos3.show; return 0; }

点击查看答案
第7题
请使用VC6或使用【答题】菜单打开考生文件夹proj3下的工程proj3,其中声明的CDeepCopy是一个用于表
示矩阵的类。请编写这个类的赋值运算符成员函数0perator=,以实现深层复制。 要求: 补充编制的内容写在“//************333************”与“//****************666*************”之间。不得修改程序的其他部分。 注意:程序最后将结果输出到文件out.dat中。输出函数writeToFile已经编译为obj文件,并且在本程序中调用。 //CDeepCopy.h include <iostream> include<string> using namespace std; class CDeepCopy { public: int n;//动态数组的元素个数 int *p;//动态数组首地址 CDeepCopy(int); ~CDeepCopy; CDeepCopy&operator=(const CDeepCopy&r);//赋值运算符函数 }; void writeToFile(char}); //main.cpp include”CDeepCopy.h” CDeepCopy::一CDeepCopy{delete[]P;} CDeepCopy::CDeepCopy(int k){n=k;p=new int[n];}//构造函数实现 CDeepCopy&CDeepCopy::0perator=(const CDeepCopy&r)//赋值运算符函数实现 { //***********333********* //***********666*********** } int main { CDeepCopy a(2),d(3); a.p[O]=1;d.p[O]=666;//对象a,d数组元素的赋值 { CDeepCopy b(3);//调用赋值运算符函数 a.p[O]=88;b=a; cout<<b.p[O];//显示内层局部对象的数组元素 } cout<<d.p[O];//显示d数组元素a.p[O]的值 cout<<”d fade away;\n”; cout<<a.p[O];//显示a数组元素a.p[O]的值 writeToFile(””); return 0; }

点击查看答案
第8题
请使用VC6或使用【答题】菜单打开考生文件夹proj2下的工程proj2,其中定义了vehiele类,并派生出moto
rcar类和bicycle类。然后以motorcar和bicycle作为基类,再派生出motorcycle类。要求将Vehicle作为虚基类,避免二义性问题。请在程序中的横线处填写适当的代码并删除横线,以实现上述类定义。此程序的正确输出结果应为:

80

150

100

1

注意:只能在横线处填写适当的代码,不要改动程序中的其他内容,也不要删除或移动“//****found****”。

include<iostream.h>

class vehicle

{

private:

int MaxSpeed;

int Weight;

public:

//*************found************

vehicle(int maxspeed,int weight):——

~vehicle{};

int getMaxSpeed{return MaxSpeed;}

int getWeight{retum Weight;}

};

//****************found************

class bicycle:——public vehicle

{

private:

int Height;

public:

bicycle(int maxspeed,int weight,int height):vehicle(maxspeed,weight),Height(height){}

int getHeight{retum Height;};

};

//*******************found**************

class motorcar:——public vehicle

{

private:

int SeatNum;

public:

motorcar(int maxspeed。int weight,int seatnum):vehicle(maxspeed,weight),SeatNum(seatnum){}

int getSeatNum{return SeatNum;};

};

//*****************found***************

class motorcycle:——

{

public:

motorcycle(int maxspeed,int weight,int height):vehicle(maxspeed,weight),bicycle(maxspeed,weight,

height),motorcar(maxspeed,weight,1){}

};

void main

{

motorcycle a(80,150,100);

cout<<a.getMaxSpeed<<endl;

cout<<a.getWeight<<endl;

cout<<a.getHeight<<endl;

cout<<a.getSeatNum<<endl;

}

点击查看答案
第9题
请使用VC6或使用【答题】菜单打开考生文件夹proj2下的工程proj2。此工程中包含一个源程序文件main.c
pp,其中有“房间”类Room及其派生出的“办公室”类0ffice的定义,还有主函数main的定义。请在程序中“//****found****”下的横线处填写适当的代码并删除横线,以实现上述类定义。此程序的正确输出结果应为: 办公室房间号:308 办公室长度:5.6 办公室宽度:4.8 办公室面积:26.88 办公室所属部门:会计科 注意:只能在横线处填写适当的代码,不要改动程序中的其他内容,也不要删除或移动“///料料found??料”。 include<isotream> using namespaee std; class Room{ //“房间”类 int room_n0;//房间号 double length;//房间长度(m) double width;//房间宽度(n1) public: Room(int the—room—n0,double the~length,double the—width):loom—no(the—room—no),length(the— length),width(the—width){} int theRoomNoeonst{return iDonl—n0;} //返回房间号 double theLengthconst{return length;}//返回房间长度 double theWidthconst{return width;}//返回房间宽度 //**********found********** double theAreaconst{_______________}//返回房间面积(矩形面积) }; class Office:public Room{//“办公室”类 char*depart;//所属部门 public: Office(int the_room_n0,double the_length,double the_width,eonst char木the_depart) //**********found********** :_______________{ depart=new char[strlen(the depart)+1]; //**********found********** strcpy(_______________); } ~Office{delete[]depart;} const char*theDepartmentconst{return depart;}//返回所属部门 }; int main{ //**********found********** Office_______________; cout<<”办公室房间号:”<<au_office.theRoomNo<<endl <<”办公室长度:”<<an office.theLength<<endl <<”办公室宽度:”<<an 0ffice.theWidth<<endl <<”办公室面积:”<<an office.theArea<<endl <<”办公室所属部门:”<<all—office.theDepartment<<endl; return 0; }

点击查看答案
第10题
请使用VC6或使用【答题】菜单打开考生目录proj3下的工程文件proj3,此工程中包含一个源程序文件proj
3.cpp,补充编制c++程序proj3.cpp,其功能是读取文本文件in.dat中的全部内容,将文本存放到doc类的对象myDoc中。然后将myDoc中的字符序列反转,并输出到文件out.dat中。文件in.dat的长度不大于1000字节。 要求: 补充编制的内容写在“//**********”与“//**********”两行之间。实现将myDoc中的字符序列反转,并将反转后的序列在屏幕上输出。不得修改程序的其他部分。 注意:程序最后已将结果输出到文件0ut.dat中,输出函数writeToFile已经给出并且调用。 //proj3.cpp include<iostream> include<fstream> include<catting> using namespace std;

class doc { private: char*sir;//文本字符串首地址 int length;//文本字符个数 public: //构造函数,读取文件内容,用于初始化新对象,filename是文件名字符串首地址 doc(char*filename); void reverse;//将字符序列反转 一doc; void writeToFile(char*filename); }; doc::doc(char}filename) { ifstream myFile(filename); int len=1001,tmp; atr=new char[1en]; length=0; while((trap=myFile.get)!=EOF) { str[1ength++]=trap; } str[1ength]=‘\0’; myFile.close; } void doc::reverse{ //将数组atr中的length个字符中的第一个字符与最后一个字符交换,第二个字符与倒数第二个 //字符交换…… //*************333*************

//*************666*************

} doc::~doe { delete[]str; } void doc::writeToFile(char*filename) { Ofstream outFile(filename); outFile<<str; outFile.close; } void main { doc myDoc(”in.dat”); myDoc.reveme; myDoc.writeToFile(”out.dat”); }

点击查看答案
重要提示: 请勿将账号共享给其他人使用,违者账号将被封禁!
查看《购买须知》>>>
重置密码
账号:
旧密码:
新密码:
确认密码:
确认修改
购买搜题卡查看答案
购买前请仔细阅读《购买须知》
请选择支付方式
微信支付
支付宝支付
点击支付即表示你同意并接受《服务协议》《购买须知》
立即支付
搜题卡使用说明

1. 搜题次数扣减规则:

功能 扣减规则
基础费
(查看答案)
加收费
(AI功能)
文字搜题、查看答案 1/每题 0/每次
语音搜题、查看答案 1/每题 2/每次
单题拍照识别、查看答案 1/每题 2/每次
整页拍照识别、查看答案 1/每题 5/每次

备注:网站、APP、小程序均支持文字搜题、查看答案;语音搜题、单题拍照识别、整页拍照识别仅APP、小程序支持。

2. 使用语音搜索、拍照搜索等AI功能需安装APP(或打开微信小程序)。

3. 搜题卡过期将作废,不支持退款,请在有效期内使用完毕。

请使用微信扫码支付(元)

订单号:

遇到问题请联系在线客服

请不要关闭本页面,支付完成后请点击【支付完成】按钮
遇到问题请联系在线客服
恭喜您,购买搜题卡成功 系统为您生成的账号密码如下:
重要提示:请勿将账号共享给其他人使用,违者账号将被封禁。
发送账号到微信 保存账号查看答案
怕账号密码记不住?建议关注微信公众号绑定微信,开通微信扫码登录功能
警告:系统检测到您的账号存在安全风险

为了保护您的账号安全,请在“简答题”公众号进行验证,点击“官网服务”-“账号验证”后输入验证码“”完成验证,验证成功后方可继续查看答案!

- 微信扫码关注简答题 -
警告:系统检测到您的账号存在安全风险
抱歉,您的账号因涉嫌违反简答题购买须知被冻结。您可在“简答题”微信公众号中的“官网服务”-“账号解封申请”申请解封,或联系客服
- 微信扫码关注简答题 -
请用微信扫码测试
欢迎分享答案

为鼓励登录用户提交答案,简答题每个月将会抽取一批参与作答的用户给予奖励,具体奖励活动请关注官方微信公众号:简答题

简答题官方微信公众号

简答题
下载APP
关注公众号
TOP