正文

关于使用ifstream读取文件的一个问题及其解决2007-02-05 10:43:00

【评论】 【打印】 【字体: 】 本文链接:http://blog.pfan.cn/otot/23125.html

分享到:

今天在用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的开头,问题解决了。奇怪。

阅读(7758) | 评论(0)


版权声明:编程爱好者网站为此博客服务提供商,如本文牵涉到版权问题,编程爱好者网站不承担相关责任,如有版权问题请直接与本文作者联系解决。谢谢!

评论

暂无评论
您需要登录后才能评论,请 登录 或者 注册