#include
using namespace std;
class complex
{
public:
\x05complex(complex &c); //深度复制构造函数
\x05complex(float r,float i); //普通构造函数
\x05void set(float r,float i); //变量重新赋值
\x05complex(); //无参构造函数
\x05friend complex add(complex &b,complex &c); //相加
\x05friend complex sub(complex &b,complex &c); //相减
friend complex mul(complex &b,complex &c); //相乘
\x05void show();
private:
\x05float real;
\x05float imag;
};
complex::complex()
{
\x05\x05real = 0;
\x05\x05imag = 0;
}
complex::complex(float r ,float i)
{
\x05real = r;
\x05imag = i;
}
complex::complex(complex &c)
{
\x05real = c.real;
\x05imag = c.imag;
}
void complex::set(float r,float i)
{
\x05real = r;
\x05imag = i;
}
void complex::show()
{
\x05cout
定义复数类complex,并使用友元函数实现复数的加法,减法,乘法,所有函数都返回c
定义复数类complex,并使用友元函数实现复数的加法,减法,乘法,所有函数都返回c
都返回complex对象.
都返回complex对象.
其他人气:954 ℃时间:2020-04-02 04:51:45
优质解答
我来回答
类似推荐
猜你喜欢
- 1What’s the chance of ________ a general election this year?
- 2在比例尺是1:1000的学校平面图上,量得操场上的长是8.5cm,宽是4cm.操场的实际面积是多少平方米?
- 3已知直角三角形直边长4米斜边坡度5%问怎么求斜边的长度?
- 4用带火星的木条检验氧气,其原理是什么
- 5我是中国人民的儿子 我深情地爱着我的祖国和人民
- 63m2=( )dm2 3dm2=( )cm2 2400dm2=( )m2 80000cm2=( )m2 50000000m2=( )km2
- 7this is a bird
- 8超氧化钾是什么?化学式是不是KO2?能与什么发生反应?
- 9连词成句:guitar,sing,the,I,piay,can,and,yes,[.]
- 10Tanner and his team found that students in classrooms with unblocked views of at least 50 feet outs