我试图使用自定义模板IO,我得到一个错误:编译器错误使用操作符“>>”与ifstream的
"error C2678: binary '>>' : no operator found which takes a left-hand operand of
type 'std::ifstream' (or there is no acceptable conversion)"
我已搜查,发现只有建议尝试,包括更多的标题,并尝试包括:string, fstream, iostream, istream, vector
。
我可以使用fstream.get(),但我试图获得空格分隔的字符串。 (我的文件的格式是这样的线路:"String1 = String2"
)
这里是我的代码:
template <typename OutType>
OutType Read(std::ifstream& in)
{
OutType out;
in >> out;
return out;
}
任何建议都非常感谢!谢谢!
(附注:不知道它是否会为编译器的考虑无所谓,但我使用Visual Studio 2013年)
什么是OutType当您尝试调用它时? – immibis
大概应该阅读[这个问题](http://stackoverflow.com/questions/4421706/operator-overloading)。 – WhozCraig