为什么这会失败?
std::string r = "Hej.whatever";
std::string const *p = &r;
std::ifstream file ((*p).c_str(), std::ios::in, std::ios::ate);
std::ifstream file ((*p), std::ios::in, std::ios::ate);
error: no matching function for call to
‘std::basic_ifstream<char>::basic_ifstream(const string&,
const openmode&, const openmode&)’
std::ifstream file ((*p), std::ios::in, std::ios::ate);
答案 0 :(得分:0)
您需要按位OR(|
)传递几种模式:
std::ifstream file ((*p), std::ios::in | std::ios::ate);
std::ifstream file2 ((*p), std::ios::in | std::ios::ate);
您可以从第一次通话中删除.c_str()
,但不需要