文件名称:2-1
-
所属分类:
- 标签属性:
- 上传时间:2012-11-16
-
文件大小:551byte
-
已下载:0次
-
提 供 者:
-
相关连接:无下载说明:别用迅雷下载,失败请重下,重下不扣分!
介绍说明--下载内容来自于网络,使用问题请自行百度
1. 自定义一个示意性的复数类型complex,其中含有若干个成员函数,使用该类可以完成复数的加法以及对复数的输出。请完成类定义,并编制主函数,说明complex类对象,对定义的各成员函数进行调用。
class complex{
double real //复数实部
double imag //复数虚部
public:
complex() //无参构造函数
complex(double r, double i) //2参构造函数
complex addCom(complex c2) //调用者对象与对象c2相加,返回complex类对象
void outCom () //输出调用者对象的有关数据(各分量)
}
进一步,在类中添加对复数进行其他基本运算(如,复数减、乘、除、取模等)的相应成员函数,并通过主函数处的调用来验证各函数的使用正确性。
-Custom schematic of a complex type complex, which contains a number of member functions, the use of this class can complete the addition of the plural and plural output. Complete the class definition, and the preparation of the main function, indicating complex class object, the definition of the member function call. class complex {double real // plural real part of the double imag // the plural imaginary part of the public: complex () // no-argument constructor complex (double r, double i) // 2 parameter constructor complex addCom (complex c2) // the caller objects and object c2 added to return the complex class object void outCom () // output the caller object related data (components)} further add class of complex basic operations (eg, complex subtraction, multiplication, division, modulo, etc.), the corresponding member functions, and through the invocation of the main function at the function to verify correctness.
class complex{
double real //复数实部
double imag //复数虚部
public:
complex() //无参构造函数
complex(double r, double i) //2参构造函数
complex addCom(complex c2) //调用者对象与对象c2相加,返回complex类对象
void outCom () //输出调用者对象的有关数据(各分量)
}
进一步,在类中添加对复数进行其他基本运算(如,复数减、乘、除、取模等)的相应成员函数,并通过主函数处的调用来验证各函数的使用正确性。
-Custom schematic of a complex type complex, which contains a number of member functions, the use of this class can complete the addition of the plural and plural output. Complete the class definition, and the preparation of the main function, indicating complex class object, the definition of the member function call. class complex {double real // plural real part of the double imag // the plural imaginary part of the public: complex () // no-argument constructor complex (double r, double i) // 2 parameter constructor complex addCom (complex c2) // the caller objects and object c2 added to return the complex class object void outCom () // output the caller object related data (components)} further add class of complex basic operations (eg, complex subtraction, multiplication, division, modulo, etc.), the corresponding member functions, and through the invocation of the main function at the function to verify correctness.
(系统自动生成,下载前可以参看下载内容)
下载文件列表
2-1.cpp
本网站为编程资源及源代码搜集、介绍的搜索网站,版权归原作者所有! 粤ICP备11031372号
1999-2046 搜珍网 All Rights Reserved.