- 36
- 0
- 约4.25千字
- 约 7页
- 2017-07-19 发布于河南
- 举报
C复数设计性综合实验
华北科技学院计算机学院综合性实验
实 验 报 告
课程名称 《C++程序设计B》
实验学期 2015 至 2016 学年 第 二 学期
学生所在系部 计算机学院
年级 13级 专业班级 网络B131
学生姓名 赵 洋 学号 201307024124
任课教师 胡英
成绩评定:
1、类及类文件、函数文件设计: A( ),B( ),C( ),D( ))))))《C++程序设计B》课程综合性实验报告
开课实验室:基础实验室二 2016年6月 3日
实验题目 复数类的设计派生 MyComplex();
MyComplex(int a);
MyComplex(int a,int b) ;
~ MyComplex();
MyComplex(const MyComplex v) ;
Mycomplex operator=(const Mycomplex rhs);
Mycomplex operator+=(const Mycomplex rhs);
Mycomplex operator-=(const Mycomplex rhs);
Mycomplex operator*=(const Mycomplex rhs);
Mycomplex operator/=(const Mycomplex rhs);
friend MyComplex operator+(MyComplex m,MyComplex n) ;
friend MyComplex operator-(MyComplex m,MyComplex n) ;
friend MyComplex operator*(MyComplex m,MyComplex n) ;
friend MyComplex operator/(MyComplex m,MyComplex n) ;
friend ostream operator(ostream s,MyComplex t);
friend istream operator(istream s,MyComplex t);
四、设计过程(包括类的数据成员、成员函数、友元函数及主函数,写出主要代码)
1.创建基本类型MyComplex;数据成员有reg,imp;表示复数的;成员函数有无参构造函数MyComplex();MyComplex(int a);
MyComplex(int a,int b),MyComplex(const MyComplex);
重载运算符,+=-=,=,=函数
Mycomplex operator=(const Mycomplex rhs);
Mycomplex operator+=(const Mycomplex rhs);
Mycomplex operator-=(const Mycomplex rhs);
Mycomplex operator*=(const Mycomplex rhs);
Mycomplex operator/=(const Mycomplex rhs);
基类析构函数~ MyComplex();
友元函数:friend MyComplex operator+(const MyComplex,const MyComplex);
friend MyComplex operator-(const MyComplex,const MyComplex);
friend MyComplex operator*(const MyComplex,const MyComplex);
friend MyComplex operator/(const MyComplex,const MyComplex);
friend bool operator==(const MyComplex,const MyComplex);
friend bool operator!=(const MyComplex,const MyComplex);
friend ostream operator(ostream,MyComplex);
friend istream operator(istream,MyComplex);
构造函数:
MyComplex::MyComplex(){
rem=0;imp=0;}
MyComplex::MyCompl
您可能关注的文档
最近下载
- 《岭外代答》的人类学解读实验——兼论宋代华夷之辨的弱化.pdf VIP
- QSH 0081-2007 探井(直井)钻井工程设计.docx VIP
- 《岭表录异》青少年读物.pdf VIP
- 资产处置委托协议书模板5篇.docx VIP
- mipi_CSI-2_specification_v1.3._高清版电子文档.pdf VIP
- QSH 0042-2007 钻井液用磺甲基酚醛树脂技术要求.docx VIP
- 《QSH0047-2007-钻井液用抗高温抗盐降滤失剂通用技术要求》.pdf VIP
- 股市主力操盘盘 口摩斯密码(原创内容,侵权必究).pptx
- 指数基金投资指南(银行螺丝钉).pdf VIP
- 《QSH0082-2007-水平井钻井工程设计要求》.pdf VIP
原创力文档

文档评论(0)