今天在用vC++编写一个文件操作时发现一个问题,原来程序如下://LLK.h class CLLK { public: CLLK(); virtual ~CLLK(); BOOL LoadMap(const char *path);} //LLK.cpp #include <fstream>using namespace std; BOOL CLLK::LoadMap(const char *path){ ifstream fin(path, ios::in);// if (!fin) return FALSE;... return TRUE;}编译时出现以下错误:--------------------Configuration: Game - Win32 Release--------------------Compiling...Game.cppGameView.cppLLK.cppD:\game\LLK.cpp(914) : error C2079: 'fin' uses undefined class 'basic_ifstream<char,struct std::char_traits<char> >'D:\game\LLK.cpp(914) : error C2078: too many initializersMainFrm.cppMapManager.cppGenerating Code...Error executing cl.exe.Creating browse info file... Game.exe - 2 error(s), 1 warning(s) 在网上查找半天,都说是因为缺少“#include <fstream>”之故,但是我明明已经在LLK.cpp一开头就加上了啊?后来终于发现,把它转移到LLK.h的开头,问题解决了。奇怪。

评论