I want to have a function that outputs certain pieces of information to a specific designated source that is inputted to the function. In code, what I mean is:
function output( source ) {
source << "hello" << endl;
}
where source can be a ofstream
or cout
. So that I can call this function like so:
output(cout)
or ofstream otp ("hello"); output(otp)
My question is, how do I characterize source
to make this work? It's fair to assume that source
will always be a member of the std
class
Thanks!