#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
using namespace std;
#include<math.h>
class Complex
{
public:
Complex(const double dReal, const double dImage)
:_dReal(dReal)
, _dImage(dImage)
{}
Complex(const Complex& complex)
{
_dReal = complex._dReal;
_dImage = complex._dImage;
}
~Complex()
{
_dReal = 0;
_dImage = 0;
}
Complex& operator=(const Complex& complex)
{
if (this != &complex)
{
_dReal = complex._dReal;
_dImage = complex._dImage;
}
return *this;
}
Complex operator+(const Complex& complex)
{
Complex temp(*this);
temp._dReal = temp._dReal + complex._dReal;
temp._dImage = temp._dImage + complex._dImage;
return temp;
}
Complex operator-(const Complex& complex)
{
Complex temp(*this);
temp._dReal = temp._d
C++实现复数类的运算符重载
最新推荐文章于 2020-12-22 20:18:45 发布