- 1、有哪些信誉好的足球投注网站(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
- 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
- 4、该文档为VIP文档,如果想要下载,成为VIP会员后,下载免费。
- 5、成为VIP后,下载本文档将扣除1次下载权益。下载后,不支持退款、换文档。如有疑问请联系我们。
- 6、成为VIP后,您将拥有八大权益,权益包括:VIP文档下载权益、阅读免打扰、文档格式转换、高级专利检索、专属身份标志、高级客服、多端互通、版权登记。
- 7、VIP文档为合作方或网友上传,每下载1次, 网站将根据用户上传文档的质量评分、类型等,对文档贡献者给予高额补贴、流量扶持。如果你也想贡献VIP文档。上传文档
查看更多
东南大学机试-B卷-答案
东南大学09级C++(下)上机试卷B-答案 一、改错题(50分)本题共10个错误,每个错误5分 #include iostream #include cstring using namespace std; class student { char *pName; public: student(); student(char *pname); student(student s); ~student(); student operator=(student s); void print(); }; student::student() //去掉void { coutConstructor; pName=NULL; cout缺省endl; } student::student ( char *pname ) { coutConstructor; pName = new char[strlen(pname)]; if ( pName ) strcpy ( pName, pname); //pName与pname互换位置 coutpNameendl; } student::student(student s) //改为student s { coutCopy Constructor; if(s.pName) { int len = strlen( s.pName ); pName = new char[len+1]; //len改为len+1 if ( pName ) strcpy (pName, s.pName); coutpNameendl; } else pName=NULL; } student::~student() { coutDestructor; if ( pName ) coutpNameendl; delete pName; //改为delete pName; } student student::operator = ( student s ) { coutCopy Assign operator; delete[] pName; if ( s.pName ) { pName = new char[strlen(s.pName)+1]; if ( pName ) strcpy ( pName, s.pName ); coutpNameendl; } else pName=NULL; return *this; //改为return *this; } void student::print( ) //改为void student::print( ) { if (pName = NULL ) cout NULL endl; else cout pName endl; } void main(void) { student s1(范英明),s2(沈俊); student *s3 = new student; *s3 = s1; //改为*s3 = s1; s1.print(); s2.print(); s3-print(); //改为s3-print(); delete s3; return; //去掉0 } 二、编程题(50分)每段代码10分,共50分。红字为要求设计的部分。 #include iostream #include fstream #include string using namespace std; class goods; ostream operator(ostream os, goods a); istream operator(istream is, goods a); class goods { string Name; //名称 int Amount; //数量 float Price; //单价 public: goods (); ~ goods (); //析构函数,将数据保存到文件中 bool IsEmpty(){ return Name==; }; friend ostream operator(ostream os, goods a); //用于直接输出数组对象 friend istream operator(istream is, goods a); }; goods:: goods () { ifstream file(goodinfo.data); if
您可能关注的文档
最近下载
- 头皮知识课件.pptx VIP
- 2025年安徽省普通高中学业水平合格性考试信息技术和通用技术上机真题卷3.docx VIP
- 第五章第二节创新实验:铜与硝酸 说课稿 2023-2024学年高一下学期化学人教版(2019)必修第二册.docx VIP
- 2025第九届“学宪法、讲宪法”知识竞赛题库(+答案解析)(中小学组).docx VIP
- 数据挖掘与机器学习全套教学课件.pptx
- 哈希cod_max_培训教材.ppt VIP
- 第五章第二节创新实验:铜与硝酸 教学设计 2023-2024学年高一下学期化学人教版(2019)必修第二册.docx VIP
- 建筑项目设计与施工配合措施.docx VIP
- 2025年辅警考试题库公安辅警.doc VIP
- 中国银行存款证明 正面资料.doc VIP
文档评论(0)