Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
std;:ofstream如果可以同时用于输出和std::ifstream输入,为什么我们还要使用std::fstream它们呢?
std;:ofstream
std::ifstream
std::fstream
这与 stringstream、istringstream 和 ostringsstream ( link ) 的情况类似。
通常您不会从同一个流中读取和写入,因此使用 ifstream 和 ofstream 更容易,因为您不必担心流状态和流位置(就像 fstream 的情况一样)。