<< to AfxMessageBox / cout
Posted on 2002-04-15
My program can be run from the command line or using an MFC GUI. During calculation, I would like error messages to be directed either to cout or popped up in a MessageBox, depending on how the user is running it. How best to do this?
My current plan is to set a flag on startup, and check it every time there is output, something like:
void ShowErrorMessage(std::string msg)
std::cout << msg;
This feels wrong - rather than
I'd like to be doing
errOutput << "My message";
Is this a better way? How would I best implement it? Although at the moment, the program will only run on Windows, I'd like to make the code as platform independent as possible.