【发布时间】:2016-07-11 22:56:42
【问题描述】:
代码如下:
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
using namespace std;
void print_file(const ifstream& dat_in)
{
if(!dat_in.is_open())
throw ios_base::failure("file not open");
string buffer;
while(getline(dat_in, buffer)); //error here
}
int main()
{
ifstream dat_in("name_of_the_file.txt");
try{
print_file(dat_in);
}
catch(ios_base::failure exc){
cout << exc.what() << endl;
}
}
我收到一个错误,即没有重载函数 std::getline 的实例与参数列表匹配。
这行代码我做了一千遍,现在是什么问题...
3 IntelliSense: no instance of overloaded function "getline" matches the argument list argument types are: (const std::ifstream, std::string) Error 1 error C2665: 'std::getline' : none of the 2 overloads could convert all the argument types
【问题讨论】: