定义类Complex如下:class Complex { public:Complex(double r=0,double i=0):Real(r),Imag(i){}; friend定义类Complex如下:class Complex{public:Complex(double r=0,double i=0):Real(r),Imag(i){};friend Complex operator +(Complex &c1,Complex &c2);
来源:学生作业帮助网 编辑:作业帮 时间:2024/11/16 00:20:16
定义类Complex如下:class Complex { public:Complex(double r=0,double i=0):Real(r),Imag(i){}; friend定义类Complex如下:class Complex{public:Complex(double r=0,double i=0):Real(r),Imag(i){};friend Complex operator +(Complex &c1,Complex &c2);
定义类Complex如下:class Complex { public:Complex(double r=0,double i=0):Real(r),Imag(i){}; friend
定义类Complex如下:
class Complex
{
public:
Complex(double r=0,double i=0):Real(r),Imag(i){};
friend Complex operator +(Complex &c1,Complex &c2);
void Display(){cout
定义类Complex如下:class Complex { public:Complex(double r=0,double i=0):Real(r),Imag(i){}; friend定义类Complex如下:class Complex{public:Complex(double r=0,double i=0):Real(r),Imag(i){};friend Complex operator +(Complex &c1,Complex &c2);
Complex operator+(Complex& a,Complex& b)
{
static c;//函数结束时为了保留值
c.Real=a.Real+b.Real;
c.Imag=a.Imag+b.Imag;
return c;
}