samedi 16 mai 2020

What is the best way to return a std::ofstream object from a function?

Imagine you have the following code:

std::ofstream create_file(// anything in there)
{
    std::ofstream File;
    /*
       other instructions
    */
    return File;
}

Is it ok to return std::ostream or there are more efficient ways to do that?

A similar question could be this, however it does not talk about what is the best way to return the object

Best in term of speed and space

Is it the same for std::ifstream ?

Aucun commentaire:

Enregistrer un commentaire