运算符重载函数出现INTERNAL COMPILER ERROR

glovej 2009-06-06 08:59:53
用的是VC++6.0,代码如下,都是书上抄的,利用友元函数实现运算符"+"的重载:
----complex.h----
#include <iostream>
using namespace std;
class complex //定义复数类
{
private:
double real,imag;
public:
complex(double r=0,double i=0) //构造函数
{
real=r;
imag=i;
}
friend complex operator + (const complex &,const complex &); //问题就出在这行,友元函数的声明
};

-----complex.cpp------
#include"complex.h"
complex operator + (const complex &a,const complex &b) //加号友元函数重载
{
return complex(a.real+b.real,a.imag+b.imag);
}

-----main.cpp------
#include"comlex.h"
int main() // 问题应该不在这里,把这个拿掉编绎问题仍然一样
{
complex c1(1,2),c2(3,4),cxres;
cxres=c1+c2;
return 0;
}


最后的错误代码完整如下:
--------------------Configuration: 1 - Win32 Debug--------------------
Compiling...
example.cpp
c:\program files\microsoft visual studio\myprojects\1\complex.h(13) : 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 时出错.

1.exe - 1 error(s), 0 warning(s)

网上有人说什么修改设置,可以我找不到他说的不使用头文件那一项,请教答人如何解决,谢谢了,尽量详细,不胜感激
...全文
62 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
十八道胡同 2009-06-06
  • 打赏
  • 举报
回复
不晓得,顶下,,

65,210

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧