我得到两种语法?即使项目构建成功,也会出现错误。在我评论过的以下位置,我的代码的某些部分在 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/