Checking if a file opened successfully with ifstream
You can simply do this: int devices::open_file(std::string _file_name) { ifstream input_stream; input_stream.open(_file_name.c_str(), ios::in); if(!input_stream) { return -1; } file_name = _file_name; return 0; } fail() is not a static method, you must call it on an instance not a type, so if you want to use fail(), replace !input_stream with input_stream.fail() in my code above. … Read more