c++ - 如何使 c++ fstream 类引用在 Visual Studio 2010 CLR 中编译

标签 c++ visual-studio-2010 developer-tools

在以下代码中,Visual Studio 2010 C++ 无法识别接受 fstream 包含但无法识别 fstream 类型:

#include <string.h>
#include <fstream>

class Test_CLR
{
    int openFlag;

    int isOpen(void)
    {
        return openFlag;
    };

    fstream testFile;
};

最佳答案

fstream 在 std 命名空间中。试试 std::fstream 吧。有关详细信息,请参阅 http://www.cplusplus.com/doc/tutorial/namespaces/

此外,您可以使用“using”关键字允许在不同范围内使用一个类型,有关更多信息,请参阅 http://www.cprogramming.com/tutorial/namespaces.html

关于c++ - 如何使 c++ fstream 类引用在 Visual Studio 2010 CLR 中编译,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8450473/

相关文章:

c++ - 用户定义的文字可以有函数作为参数吗?

c++ - 错误 : ‘chrono’ in namespace ‘std’ does not name a type

c# - Visual Studio 调试很慢

c++ - 无法在 vc++ mfc 应用程序中分配 1.5GB 内存

compiler-errors - Mac OS Lion的Bazel

c++ - C++中相同指针的两个优先级队列

c++ - OS X 将扩展与应用程序相关联

c# - 在 C# 应用程序中嵌入 IronPython - urllib 上的导入错误

javascript - 禁用时启用 console.log

html - 确定一个短暂显示的元素