沒有匹配的功能 - ifstream open()這是代碼中包含錯誤的部分:std::vector<int> loadNumbersFromFile(std::string name){
std::vector<int> numbers;
std::ifstream file;
file.open(name); // the error is here
if(!file) {
std::cout << "\nError\n\n";
exit(EXIT_FAILURE);
}
int current;
while(file >> current) {
numbers.push_back(current);
file.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
}
return numbers;}好吧,我有點不知道發生了什么。整個事情在VS中正確編譯。但是我需要用dev cpp編譯它。我在上面的代碼中注釋了拋出錯誤的行。錯誤是:調用'std :: basic_ifstream :: open(std :: string&)沒有匹配函數調用'std :: basic_ofstream :: open(std :: string&)沒有匹配函數在代碼的不同部分,我得到的錯誤如'numeric_limits不是std的成員'或'max()尚未聲明',盡管它們存在于iostream類中,并且一切都在VS中工作。為什么我收到此錯誤?
沒有匹配的功能 - ifstream open()
12345678_0001
2019-12-02 08:04:54