C++,无法打开源文件 "ifstream"Visual Studio

标签 c++ ifstream

我得到两种语法?即使项目构建成功,也会出现错误。在我评论过的以下位置,我的代码的某些部分在 Visual Studio 中以红色突出显示:

#include <vector>
#include <string>
#include <iostream>
#include <ifstream> //include is highlighted// Error: cannot open source file "ifstream"

using namespace std;

class DictionarySorter{
public:

    DictionarySorter(){

    }
    void readDic(string name){
        ifstream dicFile (name); //dicFile is highlighted here// Error: incomplete type is not allowed

    }
private:
    vector<string> v;


};

最佳答案

std::ifstream 在 header 中定义 <fstream> .没有标准标题 <ifstream> .

关于C++,无法打开源文件 "ifstream"Visual Studio,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34279106/

相关文章:

c++ - boost::asio 在 ssl 连接后发送获取请求

c++ - yaml-cpp 比较的意外结果

c++ - C++ 中有标准的日期/时间类吗?

c++ - ifstream 在一个类中

c++ - 无法让简单的 ifstream 在 Visual Studio Express 中工作

c++ - `new/malloc` 应该是 `delete/free` 的那个?

c++ - 我们什么时候应该使用 std::enable_shared_from_this

Android NDK 链接 OpenSSL

c++ - 从字符串中提取值 C++

c++ ifstream读取无法存储到短数组缓冲区中