友元函数的重载问题
#include<iostream>
using namespace std;
class complex
{
private:
double real;
double image;
public:
complex(double r=0,double i=0):real(r),image(i)
{}
friend complex operator+(complex &c1,complex &c2);
void display()
{
cout<<"("<<real<<","<<image<<")"<<endl;
}
};
complex operator+(complex &c1,complex &c2)
{
complex A(c1.real+c2.real,c2.image+c2.image);
return A;
}
int
main()
{
complex c1(2.4,3.1),c2(4.4,5.6),c3;
c3=c1+c2;
c3.display();
return 0;
}
//程序编译老出现documents and settings\administrator\桌面\a109.cpp(12) : 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
不知我的程序哪里错了???