一个友元的问题
#include<iostream>
using namespace std;
class complex
{
public:
complex(double r,double i);
void display();
friend complex operator + (complex &a,complex &b);
private:
double real;
double img;
};
complex::complex(double r,double i)
{
real=r;
img=i;
}
void complex::display()
{
cout<<real<<img;
}
complex operator + (complex &a,complex &b)
{
return complex(a.real+b.real,a.img+b.img);l
}
int main()
{
complex m(3.1,9.21),n(6.0, 5.4),d;
d=m+n;
d.display();
return 0;
}
这样写为什么老是提示错误呢
ompiling...
a.cpp
C:\Documents and Settings\Administrator\桌面\temp\a.cpp(8) : 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
执行 cl.exe 时出错.