镇海科达学校:为什么不能定义ofstream的全局变量?

来源:百度文库 编辑:杭州交通信息网 时间:2024/04/27 15:22:47
如果这样写:
#include<fstream.h>
ofstream fout;
int main()
{
fout.open("xx.txt");
fout.close();
return 0;
}
就有错误fatal error C1001: INTERNAL COMPILER ERROR
如果定义在main里面
#include<fstream.h>
int main()
{
ofstream fout;
fout.open("xx.txt");
fout.close();
return 0;
}
就编译通过,是不是我装的vc有问题?
请高手解答~~~
是哪里设置的问题么
还是版本

不是啵,上面的程序是没错的哦,我编译过的了,可以啊

全局变量必须这样:
#include<fstream.h>
ofstream fout("xx.txt");
int main()
{
//....程序
fout.close();
return 0;
}

二楼有道理