filename is an std::string, but the constructor for std::ifstream only takes C strings (nul-terminated char arrays). To get the C string corresponding to an std::string, call std::string::c_str(). For your case, that would be filename.c_str().
I really can't imagine what they were thinking when they defined that constructor.