请教这个编译错误是什么意思?怎样解决?

hetianxu 2005-03-28 10:30:42
Compiling...
11.cpp
C:\shinichi\11.cpp(95) : 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.

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

...全文
142 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
zhangfjj 2005-03-30
  • 打赏
  • 举报
回复
上面是笔误
下面这段改过来了吧
class MyComplex;
MyComplex operator + (MyComplex& C1,MyComplex& C2);
/*在使用友元重载运算符的时候,需要在类声明前面加上前导类的声明和函数的声明*/
class MyComplex
{
double re,im;
public:
MyComplex():re(0),im(0){}
MyComplex(double m_re,double m_im)
{
re=m_re;
im=m_im;
}
friend MyComplex operator + (MyComplex& C1,MyComplex& C2);
void Display()
{
cout<<re<<"+"<<im<<"i"<<endl;
}
};
MyComplex operator+ (MyComplex& C1,MyComplex& C2)//<--------------
{
double rre=C1.re+C2.re;
double rim=C1.im+C2.im;
MyComplex result(rre,rim);
return result;
}
zhangfjj 2005-03-29
  • 打赏
  • 举报
回复
在网上查了一下资料,这里有一个前导声明的问题(限于友元方式重载运算符)
需要在类声明前面进行前导类的声明和友元函数的声明。
即:前面2行,大家在编使用vc编译器时要注意。
=============
怎么没有仔细看!
zhousqy 2005-03-29
  • 打赏
  • 举报
回复
頂樓上的樓上的樓上。
hetianxu 2005-03-29
  • 打赏
  • 举报
回复
怎样解决呢?
xjp6688 2005-03-29
  • 打赏
  • 举报
回复
用BCB也不行呢
hetianxu 2005-03-29
  • 打赏
  • 举报
回复
怎么解决的啊?谢谢
zbnxiaonan 2005-03-28
  • 打赏
  • 举报
回复
好像是这样的 我以前也遇到过这样的问题
zhangfjj 2005-03-28
  • 打赏
  • 举报
回复
是在对运算符用友元方式进行重载时,碰到的这个问题吧!
这是以前回答别人的一个问题
看看这段代码
#include <iostream>
using namespace std;
class MyComplex
{
double re,im;
public:
MyComplex():re(0),im(0){}
MyComplex(double m_re,double m_im)
{
re=m_re;
im=m_im;
}
friend MyComplex operator + (MyComplex& C1,MyComplex& C2);
void Display()
{
cout<<re<<"+"<<im<<"i"<<endl;
}
};
MyComplex::MyComplex operator + (MyComplex& C1,MyComplex& C2)
{
double rre=C1.re+C2.re;
double rim=C1.im+C2.im;
MyComplex result(rre,rim);
return result;
}
int main()
{
MyComplex a(2,3),b(3,4);
MyComplex c;
c=a+b;
cout<<"a=";
a.Display();
cout<<"b=";
b.Display();
cout<<"c=";
c.Display();
return 0;
}
【注意】
这段代码的调试,在dev-c++中是可以通过,但在vc6不行,老是出现
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 informationError executing cl.exe.
在网上查了一下资料,这里有一个前导声明的问题(限于友元方式重载运算符)
需要在类声明前面进行前导类的声明和友元函数的声明。
即:前面2行,大家在编使用vc编译器时要注意。
class MyComplex;
MyComplex operator + (MyComplex& C1,MyComplex& C2);
/*在使用友元重载运算符的时候,需要在类声明前面加上前导类的声明和函数的声明*/
class MyComplex
{
double re,im;
public:
MyComplex():re(0),im(0){}
MyComplex(double m_re,double m_im)
{
re=m_re;
im=m_im;
}
friend MyComplex operator + (MyComplex& C1,MyComplex& C2);
void Display()
{
cout<<re<<"+"<<im<<"i"<<endl;
}
};
MyComplex operator+ (MyComplex& C1,MyComplex& C2)
{
double rre=C1.re+C2.re;
double rim=C1.im+C2.im;
MyComplex result(rre,rim);
return result;
}

你看看吧

64,637

社区成员

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

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