文件的关闭,ofstream类

对于ofstream类来说,析构函数会自动完成关闭吗,然后可以在这个流上打开另外一个文件吗

对于ofstream类来说,析构函数会自动完成关闭吗:会的。

然后可以在这个流上打开另外一个文件吗:不行,会失败。If the stream is already associated with a file (i.e., it is already open), calling this function fails. https://www.cplusplus.com/reference/fstream/ofstream/open/