dimanche 9 mai 2021

Does std::ofstream guarantee the old open file will be closed if opening new one?

#include <fstream>

int main()
{
    auto fout = std::ofstream("/tmp/a.txt");
    fout.open("/tmp/b.txt"); // Will "/tmp/a.txt" be closed?
    fout.open("/tmp/c.txt"); // Will "/tmp/b.txt" be closed?
}

Does std::ofstream guarantee the old open file will be closed if opening new one?

Aucun commentaire:

Enregistrer un commentaire