文件名称:cPPcourse_design
- 所属分类:
- 其他小程序
- 资源属性:
- [Windows] [Visual C] [源码]
- 上传时间:
- 2014-04-28
- 文件大小:
- 1.71mb
- 下载次数:
- 0次
- 提 供 者:
- 红楼***
- 相关连接:
- 无
- 下载说明:
- 别用迅雷下载,失败请重下,重下不扣分!
下载
别用迅雷、360浏览器下载。
如迅雷强制弹出,可右键点击选“另存为”。
失败请重下,重下不扣分。
如迅雷强制弹出,可右键点击选“另存为”。
失败请重下,重下不扣分。
介绍说明--下载内容均来自于网络,请自行研究使用
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
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