不承认IFSC++ 我正在修改C++程序,我需要给磁盘写一些值。

不承认IFSC++ 我正在修改C++程序,我需要给磁盘写一些值。,c++,ifstream,C++,Ifstream,我在include部分添加了include,然后我尝试使用ifstream,但未被识别: IntelliSense:标识符ifstream未定义 我做错了什么? 谢谢 编辑: 这是密码 #include <fstream> #include "stdafx.h" #include "CommandHandling.h" #include "Conversions.h" #include "INIFileRW.h" #include "ComPortTimeout.h" CComma

我在include部分添加了include,然后我尝试使用ifstream,但未被识别:

IntelliSense:标识符ifstream未定义

我做错了什么? 谢谢

编辑: 这是密码

#include <fstream>
#include "stdafx.h"
#include "CommandHandling.h"
#include "Conversions.h"
#include "INIFileRW.h"
#include "ComPortTimeout.h"

CCommandHandling::CCommandHandling()
{
    /* set up com port class, start from new. */
    pCOMPort = NULL;
    pCOMPort = new Comm32Port;
    ifstream test; //Here I get the error cited above
... //More code here
...
...
...

}

在没有看到您的代码的情况下,我不能确定,但我要尝试的第一件事是查看它是否接受std::ifstream


如果是这样,那么在C++中熟悉命名空间可能是一个值得做的练习——它们无处不在。你无法回避它们。我不是建议你这么做

它位于std名称空间?可能有助于显示您如何使用它。可能还需要包含,通常是fstream include istream,但这并不保证您发布的代码不会显示任何fstream使用名称空间std@克里斯没有这样建议!不要这样做;这是一个坏习惯,将来编写有意义的代码时可能会导致命名空间冲突。你会希望在几乎所有的情况下都使用完全限定的名称,直到你在遥远的将来某个时候试图在你出版的书中降低墨水成本。它有可能在更有意义的代码中引起命名冲突/冲突。使用std::作为前缀。std::fstream、std::string、std::cout等。std::ifstream在我的代码中工作。。