版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
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. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 闭环神经刺激器行业发展现状调研与投资战略规划研究报模板
- 锚索施工方案
- 六安职业技术学院课程建设方案
- 记账实操-网游企业的账务处理分录
- 2025高考物理步步高同步练习选修1练习练透第一章 1 动量
- 《民间故事》文化传承教案
- 《表里的生物》好奇心教案
- 专升本(语文)模拟试卷17(共593题)
- 山东省专升本(高等数学一)模拟试卷2(共187题)
- 统计学基础 课件 第八章 相关与回归分析
- 新人教版 高中英语必修第一册 Welcome Unit复习学案(学生版教师版)
- 地下综合管廊工程可行性研究报告页
- 小学数学《可能性》教案基于学科核心素养的教学设计及教学反思
- 大学食堂餐票模板
- 五年级上册数学课件-5.3 小数除以整数丨苏教版 (共13张PPT)
- 泔水可行性调研报告
- 网络设计IP城域网规划
- 钢带开卷机设计
- 《坚持依法治国》 全省一等奖-完整版PPT
- SN∕T 1821-2022 双钩异翅长蠹检疫鉴定方法
- 工程监理施工现场规范管理及控制要点
评论
0/150
提交评论