Answer the question
In order to leave comments, you need to log in
How to pass file path to constructor?
I created a library, the constructor must accept a string (path to the file), but an error occurs at the compilation stage:
constructor code:
Grid::Grid(string path_to_grid_txt){
ifstream grid_txt(path_to_grid_txt);
grid_txt >> height;
grid_txt >> width;
grid_nodes = new node * [height];
for(int i = 0; i < height; ++i){
grid_nodes[i] = new node [width];
for(int j = 0; j < width; ++j){
grid_txt >> grid_nodes[i][j].pass;
grid_nodes[i][j].coordinates.x = j;
grid_nodes[i][j].coordinates.y = i;
grid_nodes[i][j].n = i * width + j;
}
}
}
int main()
{
string a;
cin >> a;
Grid st(a);
return 0;
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question