📄 complex.cpp
字号:
#include "StdAfx.h"
#include ".\complex.h"
Complex::Complex(void)
{
a=b=0;
}
Complex::Complex(int aa,int bb)
{
a=aa;
b=bb;
}
Complex::~Complex(void)
{
}
Complex::Complex(const Complex &r)
{
a=r.a;
b=r.b;
}
Complex & Complex::operator =(const Complex & r)
{
a=r.a;
b=r.b;
return *this;
}
Complex Complex::operator +(const Complex &r)
{
Complex t;
t.a=a+r.a;
t.b=b+r.b;
return t;
}
Complex& Complex::operator +=(const Complex &r)
{
a=a+r.a;
b=b+r.b;
return *this;
}
Complex Complex::operator *(const Complex &r)
{
Complex t;
t.a=a*r.a-b*r.b;
t.b=a*r.b+b*r.a;
return t;
}
ostream & operator << (ostream & os,Complex &r)
{
os<<r.a<<"+"<<r.b<<"i";
return os;
}
istream & operator >> (istream & is,Complex &r)
{
is>>r.a;
is>>r.b;
return is;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -