F
Federico
I want to create an automatic log system that writes to a ofstream
(the logfile) all the output sent to screen.
I tried to make a class COutput with the operator << overloaded for
the different kind of data types, but a problem arrived when I tried
to use io manipulators such as setprecision.
I have this in class COutput:
COutput& operator<<(ios& (*fnc)(ios&)) {
(*fnc)(cout); // For the screen
(*fnc)(logfile); // For the logfile (an ofstream)
}
But it don't work. At least with the endl manipulator, it worked with:
COutput& operator<<(ostream& (*fnc)(ostream&)) {
(*fnc)(cout); // For the screen
(*fnc)(logfile); // For the logfile (an ofstream)
}
How I can make the 'automatic logger'?
What's the problem with COutput, that don't work setprecision?
Any comments are appreciated.
Federico
PD: sorry for my bad English.
(the logfile) all the output sent to screen.
I tried to make a class COutput with the operator << overloaded for
the different kind of data types, but a problem arrived when I tried
to use io manipulators such as setprecision.
I have this in class COutput:
COutput& operator<<(ios& (*fnc)(ios&)) {
(*fnc)(cout); // For the screen
(*fnc)(logfile); // For the logfile (an ofstream)
}
But it don't work. At least with the endl manipulator, it worked with:
COutput& operator<<(ostream& (*fnc)(ostream&)) {
(*fnc)(cout); // For the screen
(*fnc)(logfile); // For the logfile (an ofstream)
}
How I can make the 'automatic logger'?
What's the problem with COutput, that don't work setprecision?
Any comments are appreciated.
Federico
PD: sorry for my bad English.