Joã*_*res 5 c++ binary fstream
在搜索 C++ 中的文件读取示例时,我注意到许多示例使用
std::ios::binary与std::ifstream::binarystd::ios::beg与your_file_stream.begstd::ios::end与your_file_stream.end这些示例有什么区别吗?如果没有,为什么它们都包含在 STL 中?
std::ios::binaryvs.std::ifstream::binary很大程度上取决于个人选择,但我总是使用更“基本”的定义,因为如果您明白我的意思,它就位于继承树的更上层。这std::ios::binary就是我的选择。
至于std::ios::beg和your_file_stream.beg,我更倾向于前者:static通过实例联系成员是毫无意义且令人困惑的。