My code has an ostream object, which is accumulated by various modules and is ultimately displayed on the console. I would also like to write this ostream object to a file, but I need to rewrite all this code using the ofstream object instead, or is there a way to convert one to another (maybe via stringstream ?)
For example, many of my existing functions look like
ostream& ClassObject::output(ostream& os) const { os << "Details"; return os; }
Is it possible to call this function with an ofstream object as an argument and, instead, an ofstream object ofstream accumulate information?
source share