I would like to change a function that displays some info about the class so that
can print to the screen or write to a file depending on the kind of stream I am passing to the function.
I would like to have a function like:
void output(int x, default (what class do I need here??) &stream=cout){
stream << x ;
}
What is the proper way to do that???
Thanks for the help!
You generally want
std::ostream&. Note that most programmers would just overloadoperator<<rather than define a separateoutput()function like you’ve done.