classComplex{public:Complex();Complex(intreal,irtual);voidSetComplex(intreal,irtual);voidPrintComplex();ComplexAdd(Complexc);private:inta;intb;};Complex::Complex(){}Complex::Complex(intreal,irtual){a=real;b=virtual;}voidComplex::SetComplex(intreal,irtual){a=real;b=virtual;}voidComplex::PrintComplex(){cout
complex是复数。函数定义,运算符加号重载,两个形参(复数c1,c2),函数返回一个复数,它的实部是c1.real c2.real,虚部是c1.imag c2.imag,
第二个是一个模版函数,由此函数可以根据classX展开成各种类型的版本,例如int,charfloat,long等等版本