fatal error C1001: INTERNAL COMPILER ERROR
重载运算符,下面是c++编程思想上的范式:
#include "stdafx.h "
#include <iostream>
using namespace std;
//non-memeber functions
//class Integer:
class Integer {
long i;
Integer* This() { return this; }
public:
Integer(long ll = 0) : i(ll) {}
//no side effects takes const& arg
friend const Integer&
operator+(const Integer& a);
friend const Integer
operator-(const Integer& a);
friend const Integer
operator~(const Integer& a);
friend Integer*
operator&(Integer& a);
friend int
operator!(const Integer& a);
//side effects have non-const& arg
friend const Integer& //prefix
operator++(Integer& a);
friend const Integer //postfix
operator++(Integer& a, int);
friend const Integer& //prefix
operator--(Integer& a);
friend const Integer //postfix
operator--(Integer& a, int);
};
//realize:
//global operators:
const Integer& operator+(const Integer& a) {
cout < < "+Integer\n ";
return a;
}
const Integer& operator-(const Integer& a) {
cout < < "-Integer\n ";
return Integer(-a.i);
}
const Integer& operator~(const Integer& a) {
cout < < "~Integer\n ";
return Integer(~a.i);
}
Integer* operator&(Integer& a) {
cout < < "&Integer\n ";
return a.This(); //a? &a?
}
int operator!(const Integer& a) {
cout < < "!Integer\n ";
return !a.i;
}
//prefix:
const Integer& operator++(Integer& a) {
cout < < "++Integer\n ";
a.i++;
return a;
}
//postfix:
const Integer operator++(Integer& a ,int) {
cout < < "Integer++\n ";
Integer before(a.i);
a.i++;
return before;
}
//prefix:
const Integer& operator--(Integer& a) {
cout < < "--Integer\n ";
a.i--;
return a;
}
//postfix:
const Integer operator--(Integer& a , int) {
cout < < "Integer--\n ";
Integer before(a.i);
a.i--;
return before;
}
//show that member functions work
void f(Integer a) { //not Integer& a
+a;
-a;
~a;
Integer* p = &a;
!a;
++a;
a++;
--a;
a--;
}
int main(){}
错误提示:
d:\vc\myprojects\page266\page266.cpp(16) : 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.
page266.obj - 1 error(s), 0 warning(s)
按照网上提供的几个方法都无法解决,如:
1,Not using precompiled preheader;
2,修改project options 中/Zm#nn的#nn为1000等
都不行,查资料说这是微软产品的一个BUG,只会出现在win95和98上,但是我的是xp sp2啊,怎么回事啊?谢谢解答
[解决办法]
VC6吧?sp6打了没有?或者装的防病毒软件暂时关掉。
建议换VC2005express,学C++的话还是扔了VC6吧。
[解决办法]
CygWin
