奇怪现象

weiyijiji 2008-07-08 03:51:05
定义1个类,在CPP中实现构造函数会出现“C:\Program Files\Microsoft Visual Studio\MyProjects\prog1\prog1.cpp(45) : fatal error C1001: INTERNAL COMPILER ERROR (compiler file 'msc1.cpp', line 1786) ......
的错误,把构造函数在H中实现就么这个问题了.不知道是为是么
...全文
126 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
npuhuxl 2008-07-08
  • 打赏
  • 举报
回复
在VS2008中编译未出现问题,估计是楼主的编译器有些问题。
weiyijiji 2008-07-08
  • 打赏
  • 举报
回复
[Quote=引用 7 楼 newerC 的回复:]
/*rectangleclass::rectangleclass(){
length=width=area=0; //在这里实现会报错
};*/

}后多了一个分号
[/Quote]
没分号,刚才复制时手误了.不过奇怪了,现在编译能通过,而且不论有无;号
newerC 2008-07-08
  • 打赏
  • 举报
回复
/*rectangleclass::rectangleclass(){
length=width=area=0; //在这里实现会报错
};*/

}后多了一个分号
weiyijiji 2008-07-08
  • 打赏
  • 举报
回复
贴上原码
.H文件
#ifndef _RECTANGLE1_H
#define _RECTANGLE1_H
#include <iostream.h>

class rectangleclass{
public:
rectangleclass(){
length=width=area=0; //在这里实现么问题
};
void GetNum(int l,int w);
void Show();

~rectangleclass();

private:
int length;
int width;
int area;

};
#endif


.CPP
#include "rectangleclass.h"

/*rectangleclass::rectangleclass(){
length=width=area=0; //在这里实现会报错
};*/
void rectangleclass::GetNum(int length,int width){
this->length=length;
this->width=width;
this->area=this->length*this->width;
}
void rectangleclass::Show(){

cout<<"Length:"<<length<<endl;
cout<<"Width:"<<width<<endl;
cout<<"Area:"<<area<<endl;

}
rectangleclass::~rectangleclass(){

cout<<"Over"<<endl;
}
int main(){
rectangleclass r;
int length,width;
cout<<"Input the length:"<<endl;
cin>>length;
cout<<"Input the width:"<<endl;
cin>>width;
r.GetNum(length,width);
r.Show();

return 0;
}
weiyijiji 2008-07-08
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 wanggang999 的回复:]
line 1786???你这文件够长的啊,
方便的话把代码贴上来看看呗。

既然你就给出这些东西,不如看看MSDN怎么说的吧:


Error Message
INTERNAL COMPILER ERROR(compiler file file, line number)


The compiler cannot generate correct code for a construct, probably due to the combination of an expression and an optimization option. Try removing one or more optimization options and recompiling th…
[/Quote]
那个CPP不是我的文件
windsting 2008-07-08
  • 打赏
  • 举报
回复
line 1786???你这文件够长的啊,
方便的话把代码贴上来看看呗。

既然你就给出这些东西,不如看看MSDN怎么说的吧:


Error Message
INTERNAL COMPILER ERROR(compiler file file, line number)


The compiler cannot generate correct code for a construct, probably due to the combination of an expression and an optimization option. Try removing one or more optimization options and recompiling the function containing the line indicated in the error message.

You can probably fix the problem by removing one or more optimization options. To determine which option is at fault, remove options one at a time and recompile until the error message goes away. The options most commonly responsible are /Og, /Oi, and /Oa. Once you determine which option is responsible, you can disable it using the optimize pragma around the function where the error occurs and continue to use the option for the rest of the module.

The Microsoft Knowledge Base has more information about C1001; see http://support.microsoft.com/default.aspx?scid=kb;en-us;134650.

Try rewriting the line where the error is reported, or several lines of code surrounding that line. If that doesn't work, contact Microsoft Product Support Services.
taodm 2008-07-08
  • 打赏
  • 举报
回复
vc6,没打sp6补丁。
aleaf 2008-07-08
  • 打赏
  • 举报
回复
没包括头文件?
bargio_susie 2008-07-08
  • 打赏
  • 举报
回复
贴代码。

64,639

社区成员

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

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