小白今天演练c++中的运算符重载,在调试的过程中发现报错如下:
E:\work\C-C++\practice\capter10\10-3\10-3.cpp(11) : 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 时出错.
小白前前后后检查了代码3遍,没发现什么异常,网上搜了一圈后结果如下:
此错误为Microsoft 的visual Stdio 2008(V6.0)里有一个bug,在V6.0里还未完全实现C++标准,所提供的不带.h后缀的头文件不支持把运算符重载函数作为友元函数,但是Visual C++老版本的带后缀的.h可以支持此项功能(如方法二)解决方法如下:
方法一:
将
#icnlude<iostream>
using namespace std;
替换成:
#include<iostream>
using std : : cout ;
using std : : endl ;
方法二:
将
#icnlude<iostream>
using namespace std;
替换成:#include<iostream.h>