作业帮 > 综合 > 作业

定义复数类,实现复数的相加相减,用c++编程,急,请大伙帮帮忙

来源:学生作业帮 编辑:大师作文网作业帮 分类:综合作业 时间:2024/11/10 12:34:42
定义复数类,实现复数的相加相减,用c++编程,急,请大伙帮帮忙
定义复数类,实现复数的相加相减,用c++编程,急,请大伙帮帮忙
#include
#include
using namespace std;
class Complex
{
private:
double real,imag;
public:
Complex()
{
}
Complex(double rea,double ima)
{
real=rea;
imag=ima;
}
Complex operator++(int)
{
real++;
imag++;
return Complex(real-1,imag-1);
}
friend istream&operator>>(istream&istr,Complex&x);
friend ostream&operator(istream&istr,Complex&x)
{
istr>>x.real>>x.imag;
return istr;
}
ostream&operato