我正在开发一个Windows的VC++ 2008程序,它执行fileIO,并且遇到了一个非常奇怪的问题。在我的#include指令我有ios not recognized
#include "stdafx.h"
#include <iostream>
#include <fstream>
#include <string>
,然后我有实际执行FILEIO的方法,但是当我尝试打开这样的文件:
std::ofstream Output;
Output.open("Output/log.txt", ios::out);
我的智能感知允许,和甚至有正确的自动完成,但我的编译器引发的错误:
1>c:...\engine\gsp420maincore\gsp420maincore\messagequeue.cpp(141) : error C2653: 'ios' : is not a class or namespace name
1>c:...\engine\gsp420maincore\gsp420maincore\messagequeue.cpp(141) : error C2065: 'out' : undeclared identifier
当我读到有关ofstream.open()就指出,要打开的文件是否是用于输入,输出,或两者应该是SPECI田间,但是IOS应该会自动通过任何其他的iostream #include指令包括,当我插入这个问题没有解决的:
#include <ios> // directive
编译器有没有投诉,当我删除第二个说法,但我知道,我应该尝试,并指定以防万一我想从文件中读入并写入文件。我做错什么了吗?
你的意思是'std :: ios'? – wilhelmtell 2012-01-30 05:44:14
是的,我确实需要说明。显然是因为这个文件是在使用namespace指令之前编译的,所以我必须指定它驻留在std中 – gardian06 2012-01-30 05:48:46