I have a function I'm writing that should handle output differently if it gets passed a file stream vs if it gets passed the console out. I could write two functions, one to handle cout and one to handle the fstream, and throw them in an if statement to determine which is called, or could add a bool on which version to run, but it'd be simpler to verify the output passed to the function, in my opinion. My first attempt was
void print(unsigned long long exp, unsigned long long* total,
ostream& out, unsigned long long min, unsigned long long max, unsigned
long long length)
{
if (out == cout)
...
}
Is there a way to overload == to compare these or a function that compares these?