I am considering writing several lines into a file in C++ using ofstream and the text is composed of several parts (strings and numbers), so essentially I know there are two ways.
Here is a simple example:
// Way 1 (Use several '<<')
f << str1 << " " << 10 << "Text" << std::endl;
// Way 2 (Use plus to have a continuous string)
f << str1 + " " + std::to_string(10) + "Text" << std::endl;
So which one is preferred (or maybe use append instead of +) in terms of efficiency and other criteria?