\new\Complex\Complex.h|19|error: expected initializer before 'operator'|
原程序对应部分是
#include <iostream>
using namespace std;
class Complex {
friend Complex operator+(const Complex &r1, const Complex &r2);
friend Complex operator-(const Complex &r1, const Complex &r2);
friend Complex operator*(const Complex &r1, const Complex &r2);
friend ostream & operator<<(ostream & os,const Complex &r1);
private:
int real, imag;
public:
Complex (double r, double i) {real = r; imag = i;}
~Complex(){};
}
Complex operator+(const Complex &r1, const Complex &r2)
{ Complex tmp(0,0);
tmp.real = r1.real + r2.real;
tmp.imag = r1.imag + r2.imag;
return tmp;}
跪求大神指点
原程序对应部分是
#include <iostream>
using namespace std;
class Complex {
friend Complex operator+(const Complex &r1, const Complex &r2);
friend Complex operator-(const Complex &r1, const Complex &r2);
friend Complex operator*(const Complex &r1, const Complex &r2);
friend ostream & operator<<(ostream & os,const Complex &r1);
private:
int real, imag;
public:
Complex (double r, double i) {real = r; imag = i;}
~Complex(){};
}
Complex operator+(const Complex &r1, const Complex &r2)
{ Complex tmp(0,0);
tmp.real = r1.real + r2.real;
tmp.imag = r1.imag + r2.imag;
return tmp;}
跪求大神指点