文件名称:cPPcourse_design

  • 所属分类:
  • 其他小程序
  • 资源属性:
  • [Windows] [Visual C] [源码]
  • 上传时间:
  • 2014-04-28
  • 文件大小:
  • 1.71mb
  • 下载次数:
  • 0次
  • 提 供 者:
  • 红楼***
  • 相关连接:
  • 下载说明:
  • 别用迅雷下载,失败请重下,重下不扣分!

介绍说明--下载内容均来自于网络,请自行研究使用

1、【拷贝构造函数】定义一个复数类CComplex



class CComplex {



private:



float real //实部



float imag //虚部



public:



CComplex(float x =0.0 , float y = 0.0):real(x),imag(y) {}



CComplex(CComplex& c)



CComplex operator+(CComplex& c)



CComplex operator-(CComplex& c)



void print() const { cout << real << " + " << imag << "i" << endl



}





void main() {





CComplex c1(3, 5), c2(4, 7)



CComplex c3 = c1 + c2



CComplex c4 = c2 - c1



c4.print()



c3.print()



}



请完善CComplex的拷贝构造函数、运算符重载+和-,使其完成指定功能。



2、【继承】正方形为矩形的一个特例,请定义正方形类(CSquare)和矩形类(CRectangle),将正方形类定义为矩形类的派生类。



(1)矩形具有计算周长、面积的成员函数;



(2)正方形作为子类还具有计算内切圆的周长和面积的成员函数; -1, [] define a copy constructor complex class CComplex



class CComplex {



private:



float real // real part



float imag // imaginary part



public:



CComplex (float x = 0.0, float y = 0.0): real (x), imag (y) {}



CComplex (CComplex & c)



CComplex operator+ (CComplex & c)



CComplex operator-(CComplex & c)



void print () const {cout << real << "+" << imag << "i" << endl



}





void main () {





CComplex c1 (3, 5), c2 (4, 7)



CComplex c3 = c1+ c2



CComplex c4 = c2- c1



c4.print ()



c3.print ()



}



Please improve the copy constructor CComplex of operator overloading+ and- to complete the assigned functions.



2, [inheritance] square is a special case of a rectangle, define a square class (CSquare) and rectangular class (CRectangle), defined as the square class derived class rectangle class.



(1) having a rectangular perimeter calculation, the area of ​ ​ member functions



(2) as a sub-class also has
(系统自动生成,下载前可以参看下载内容)

下载文件列表





c++课程设计\C_course_work_1\C_course_work_1

...........\...............\C_course_work_1.cpp

...........\...............\C_course_work_1.dsw

...........\...............\C_course_work_1.ncb

...........\...............\C_course_work_1.opt

...........\...............\C_course_work_1.plg

...........\...............\Debug\C_course_work_1.exe

...........\...............\.....\C_course_work_1.ilk

...........\...............\.....\C_course_work_1.obj

...........\...............\.....\C_course_work_1.pch

...........\...............\.....\C_course_work_1.pdb

...........\...............\.....\Rectangle.obj

...........\...............\.....\Square.obj

...........\...............\.....\vc60.idb

...........\...............\.....\vc60.pdb

...........\...............\Rectangle.cpp

...........\...............\Rectangle.h

...........\...............\Square.cpp

...........\...............\Square.h

...........\..............2\Complex.cpp

...........\...............\Complex.h

...........\...............\C_course_work_2.cpp

...........\...............\C_course_work_2.dsp

...........\...............\C_course_work_2.dsw

...........\...............\C_course_work_2.ncb

...........\...............\C_course_work_2.opt

...........\...............\C_course_work_2.plg

...........\...............\Debug\Complex.obj

...........\...............\.....\C_course_work_2.exe

...........\...............\.....\C_course_work_2.ilk

...........\...............\.....\C_course_work_2.obj

...........\...............\.....\C_course_work_2.pch

...........\...............\.....\C_course_work_2.pdb

...........\...............\.....\vc60.idb

...........\...............\.....\vc60.pdb

...........\..language_project_design\C_course_work_x.txt

...........\..course_work_1\Debug

...........\..............2\Debug

...........\C_course_work_1

...........\C_course_work_2

...........\C_language_project_design

c++课程设计

readme.txt

相关说明

  • 本站资源为会员上传分享交流与学习,如有侵犯您的权益,请联系我们删除.
  • 本站是交换下载平台,提供交流渠道,下载内容来自于网络,除下载问题外,其它问题请自行百度更多...
  • 请直接用浏览器下载本站内容,不要使用迅雷之类的下载软件,用WinRAR最新版进行解压.
  • 如果您发现内容无法下载,请稍后再次尝试;或者到消费记录里找到下载记录反馈给我们.
  • 下载后发现下载的内容跟说明不相乎,请到消费记录里找到下载记录反馈给我们,经确认后退回积分.
  • 如下载前有疑问,可以通过点击"提供者"的名字,查看对方的联系方式,联系对方咨询.

相关评论

暂无评论内容.

发表评论

*主  题:
*内  容:
*验 证 码:

源码中国 www.ymcn.org