Change
ifstream file(filename);
to
ifstream file(filename.c_str());
Because the constructor for an ifstream takes a const char*, not a string pre-C++11.
Change
ifstream file(filename);
to
ifstream file(filename.c_str());
Because the constructor for an ifstream takes a const char*, not a string pre-C++11.