运算符重载问题,看不懂错误提示
#include <iostream>using namespace std;
class Complex
{public:
friend Complex operator + (Complex &c1,Complex &c2);
Complex(double r=0,double i=0){real=r;imag=i;}
double get_real();
double get_imag();
void display();
double real;
double imag;
};
double Complex::get_real()
{return real;}
double Complex::get_imag()
{return imag;}
Complex operator + (Complex &c1,Complex &c2)
{Complex c;
c3.real=c1.get_real()+c2.get_real();
c3.imag=c1.get_imag()+c2.get_imag();
return c ;
}
int main()
{Complex c1(3,4),c2(5,-10),c3;
c3=c1+c2;
cout<<"c3=";
cout<<c3;
return 0;
}
错误:fatal error C1001: INTERNAL COMPILER ERROR
(compiler file 'msc1.cpp', line 1786)
Please choose the Technical Support command on the Visual C++
Help menu, or open the Technical Support help file for more information
Error executing cl.exe.