fatal error C1001: INTERNAL COMPILER ERROR VC6.0BUG
这是微软VC6.0的Bug
不要用using namespace std; 改成 using std::cout; using std::endl;就可以了
如以下代码:
// 运算符重载.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include <IOSTREAM> using namespace std; class Person { public: int m; Person(int m = 100) { this->m = m; } friend void operator+(int salary, Person& p) { p.m += salary; } }; int main(int argc, char* argv[]) { Person p; 1000+p; cout<<p.m<<endl; return 0; }
修改后的代码:
调试通过// 运算符重载.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include <IOSTREAM> using std::cout; using std::endl; class Person { public: int m; Person(int m = 100) { this->m = m; } friend void operator+(int salary, Person& p) { p.m += salary; } }; int main(int argc, char* argv[]) { Person p; 1000+p; cout<<p.m<<endl; return 0; }