问题描述如下:
error: no matching function for call to 'std::basic_ifstream::basic_ifstream(std::__cxx11::string&)'|
源码如下:(请问哪位大神解答下?)
#include <iostream>
#include <vector>
#include<fstream>
#include<string.h>
#include <cstring>
//#include<string>
using namespace std;
vector < vector <char> > read_map(string file_name);
vector <char> read_line(string s);
int main () {
read_map("maps/m1.txt");
// TODO: Nothing to do here
return 0;
}
vector < vector <char> > read_map(string file_name) {
ifstream infile(file_name);
vector < vector <char> > map;
if (infile.is_open()) {
char color;
vector <char> row;
string line;
while (std::getline(infile, line)) {
row = read_line(line);
map.push_back(row);
}
}
return map;
}
vector <char> read_line(string s) {
vector <char> row;
size_t pos = 0;
string token;
string delimiter = " ";
char cell;
while ((pos = s.find(delimiter)) != std::string::npos) {
token = s.substr(0, pos);
s.erase(0, pos + delimiter.length());
cell = token.at(0);
row.push_back(cell);
}
return row;
}