Reputation: 335
I Declared: std::string input_file="1.txt";
then I tried to do this command:
static ifstream myfile (input_file);
and I get the error: no matching function for call to : std::basic_ifstream<char>::basic_ifstream(std::string&)
Upvotes: 1
Views: 507
Reputation: 22099
Try:
static ifstream myfile(input_file.c_str());
For some reason, the ifstream
constructor doesn't accept an std::string
.
Upvotes: 6