


版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
08C++(下)上机试卷学 机位号说明:首先在Z自己的学号命名的文件夹,用于存放上交的*.CPP交时只保留文件夹中的CPP文件。【注意】源程序以“学号f1.cpp”命名,存入自己 夹 构造函数和赋值操作操作符实现深。#include<iostream>#include<cstring>usingnamespacestd;classstudent{student(studentchar*pnameintlen1student(student&s);student&operator=(student&s {cout>>"Constructor"; pName=NULL;cout默认}student::student(char*pname{cout<<pName=newif(pName)strcpy(pName,pname);cout<<pName<<endl;}student::studentstudents {if(s.pName) intlen=pName=newchar(len+1); if(pName)strcpy(pName,s.pName);cout<<pName<<}elsepName=}{cout<<ifpNamecoutpNameendl;deletePName; //6}student&Student::operatorstudent&s {cout<<"CopyAssignoperator";delete[]pName;{len=strlen(s.pName); //8pNamenewchar[len];//9ifpNamestrcpypNames.pNamecout<<pName<<endl;}elsepNa return*this;}int{students1("范英明"),s2("");students3(s1);student*s4newstudent(s2);deletes3; //错误10return0;}二、编程题(50分【注意】源程序以“学号f2.cpp”命名,存入自己学夹产品销售价=原材料价格*1.5+加工费*2.0【注意】将源程序以文件名“学号f2.cpp”存入Zusingnamespacestd;classProduct{材材void{} }void{}int{Productpro;return0;}【提醒】上传的学夹中只需包含f1.cpp、f2.cpp及Output.txt三个文件即08C++(下)上机试卷D#include<iostream>#include<cstring>usingnamespacestd;classstudent student(student(char*pname*intlen*/);//(1)掉intlen,student(char*pname);student(student&s);~student(student&operator=(student&s cout<<"Constructor"; pName=NULL;cout默认}student::student(char*pname cout<<pName=newchar[strlen(pname)+1];if(pName)strcpy(pName,pname);cout<<pName<<endl;}student::student(student&s 4)students改为student{cout<<"CopyConstructor";if(s.pName) intlen=pNamenew (5)括号改为方括if(pName)strcpy(pName,s.pName);cout<<pName<<endl;}elsepName=} cout<<if(pName)cout<<pName<<delete //(6)增加delete}student&student::operatorstudent&s 7Student改为{cout<<"CopyAssignoperator";delete[]pName; intlen=strlen(s.pName); //(8)len改为intlenpName=newchar[len+1]; //(9)len改为len+1if(pName)strcpy(pName,s.pName);cout<<pName<<}elsepNaLL;return*this;}int students1("范英明"),s2("");students3(s1);student*s4=newdeletes3; 10)deletes4return0;}usingnamespacestd;class{//原材料进void{ifstream //只} infile>>ProductName>>MatName>>MatPrice0>>ServicePrice;}}{ofstreamif(!outfile) }outfile产品名称ProductNameendl;outfile<<"原材料名称:"<<MatName<<endl;outfile原材料价格MatPrice0endl;outfile<<"加
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2024年农业植保员考试回顾与展望试题及答案
- 2024年种子繁育员的实施方案试题及答案
- 给力2024游泳救生员考试试题及答案
- 掌握不足2024年农业植保员资格考试的试题与答案研究
- 剖析课程 2024年体育经纪人考试的职业知识与应用技巧试题及答案
- 电子商务设计师复习试题附答案(一)
- 2024年篮球裁判员考试中自我提升的策略 试题及答案
- 2024年足球裁判员考试重要事项试题及答案
- 无人机经济效益评估的试题及答案
- 2024年体育经纪人职业发展的机遇试题及答案
- 舞台人生走进戏剧艺术学习通期末考试答案2023年
- 新《用字母表示数》说课
- 河南省矿山储量动态检测技术指南
- 光学系统的像质评价和像差公差
- :AHA心肺复苏和心血管急救指南(完整版)
- 垃圾焚烧炉渣综合利用方案
- 12J1 工程做法 天津市建筑标准设计图集(2012版)
- 专卖执法人员资格考试题库
- 全要素加强化工过程安全管理
- 腹部按压技巧肠镜检查辅助技巧
- 5月业务学习第一篇输液港的使用及维护
评论
0/150
提交评论