#include"iostream.h"
class complex
{
private:
double real;
double imag;
public:
complex(){}
complex(double r,double i)
{
real=r;
imag=i;
}
void display()
{
cout<<"("<<real<<","<<imag<<")"<<endl;
}
complex operator +(complex ct) 运算符的重载;
{
complex c; 复数类型的对象;
c.real=this->real+ct.real; 当前指向的real+ct.real赋值给c.real
c.imag=this->imag+ct.imag;
}
};
void main()
{
complex c1(5,3.255); 调用参数
complex c2(4,5.425);
complex c;
c1.display();
c2.display();
c.display();
}