东南08级试卷电类下机试试卷_第1页
东南08级试卷电类下机试试卷_第2页
东南08级试卷电类下机试试卷_第3页
已阅读5页,还剩2页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

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. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论