c++中运算符重载遇到的问题

来源:互联网 发布:手机淘宝 退货率 编辑:程序博客网 时间:2024/05/27 09:45

 h:/test/complex2.h(23) : 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.

test.exe - 1 error(s), 0 warning(s)
刚才上机遇到这个问题,急得我要死。

 

到网上搜了一下与运算符重载有关。出错的是这句话:using namespace std;

 

在头文件里注释掉这句,但是保留#include <iostream>

OK!!!

将#include <iostreami>改为#include <iostreami.h>   ,也OK!!!

 

这有解答

http://topic.csdn.net/t/20051219/09/4467018.html

 

造成这种问题的原因是编译器分配的内存超过了限制。
解决的办法有三种
1.给编译器增大内存限制。在project(工程)->setting(设置)->c/c++的project option(工程选项)中,添加/Zm#nn选项,#nn是一个数字,取值最大为2000。默认为100。但是这种方法好像没有什么用处。
2.将模板类头文件从stdafx.h中移出;
3.不使用预编译头文件。project->setting->c/c++,选择所有的.cpp文件,都使用“不使用预编译头文件“的选项。缺点是编译的时候很慢

原创粉丝点击