运算符重载INTERNAL COMPILER ERROR错误

chengsiping 2009-12-06 09:52:21
运算符重载 fatal error C1001: INTERNAL COMPILER ERROR 每次用到friend函数就出现这样的错误 不知道是什么原因
...全文
139 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
mstlq 2009-12-06
  • 打赏
  • 举报
回复
VC6.0的一个编译错误的解决

在window98下使用vc6.0时,如果预编译头文件(stdafx.h)中包含了模板类的头文件,比如atl的头文件时,编译器会报错:
fatal error C1001: INTERNAL COMPILER ERROR
(compiler file 'msc1.cpp', line 1786)

造成这种问题的原因是编译器分配的内存超过了限制。
解决的办法有三种:
1.给编译器增大内存限制。在project(工程)->setting(设置)->c/c++的project option(工程选项)中,添加/Zm#nn选项,#nn是一个数字,取值最大为2000。默认为100。但是这种方法好像没有什么用处。
2.将模板类头文件从stdafx.h中移出;
3.不使用预编译头文件。project->setting->c/c++,选择所有的.cpp文件,都使用“不使用预编译头文件“的选项。缺点是编译的时候很慢。
chengsiping 2009-12-06
  • 打赏
  • 举报
回复
#include<iostream>
using namespace std;
class Matrix
{
public:
Matrix();
friend Matrix operator+(Matrix &,Matrix &);
void input();
void display();
private:
int mat[2][3];
};
Matrix::Matrix()
{
for(int i=0;i<2;i++)
for(int j=0;j<3;j++)
mat[i][j]=0;
}
Matrix operator+(Matrix &a,Matrix &b)
{
cout<<"input value of matrix:"<<endl;
for(int i=0;i<2;i++)
for(int j=0;j<3;j++)
{c.mat[i][j]=a.mat[i][j]+b.mat[i][j];}
return c;
}
void Matrix::input()
{
cout<<"input value of matrix:"<<endl;
for(int i=0;i<2;i++)
for(int j=0;j<3;j++)
cin>>mat[i][j];
}
void Matrix::display()
{
for(int i=0;i<2;i++)
{for(int j=0;j<3;j++)
{cout<<mat[i][j]<<" ";}
cout<<endl;}

}
int main()
{
Matrix a,b,c;
a.input();
b.input();
cout<<endl<<"Matrix a:"<<endl;
a.display();
cout<<endl<<"Matrix b:"<<endl;
b.display();
c=a+b;
cout<<endl<<"Matrix c=Matrix a+Matrix b:"<<endl;
c.display();
return 0;
}
--------------------Configuration: xt8-4-1 - Win32 Debug--------------------
Compiling...
xt8-4-1.cpp
D:\test\书上练习_1\xt8-4-1.cpp(7) : 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 时出错.

xt8-4-1.exe - 1 error(s), 0 warning(s)
kouwenlong 2009-12-06
  • 打赏
  • 举报
回复
代码?

64,673

社区成员

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

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