1.

#include
using namespace std;
class Complex
{
	public:
		Complex(double r,double i):real(r),imag(i){}
		Complex operator +(Complex &s);
		void display();
	private:
		double real;
		double imag;
};
Complex Complex:: operator +(Complex &s)
{
	return(Complex(real+s.real,imag+s.imag));
}
void Complex::display()
{
	cout<
1._第1张图片

你可能感兴趣的:(第四章运算符的重载)