I am using Visual Studio for the project I am working on, although it must also compile with GCC on Linux. I completed my project and it works fine, but I sent the files to my Linux shell and I get an error with a trivial line of code:
std::ifstream input(s);
This gives me an error saying that there is no corresponding function. s- it is std::string. Can someone enlighten me why this works under Visual Studio, but not with GCC, although I am looking at the documentation for ifstream? Perhaps the old version of GCC?
EDIT : GCC Version 4.2.1. Exact error:
error: no matching function for call to 'std::basic_ifstream<char,
std::char_traits<char>>::basic_ifstream(std::string&)'
EDIT 2: Corresponding code:
std::string s = "";
if(argc == 2)
s = argv[1];
else{
std::cout << "Bad filename?" << std::endl;
return 1;
}
std::ifstream input(s);
source
share