ok, let's say i have a function call it foo.
foo wants to be able to look like this:
void foo (<output stream> s, int o)
{
s << "blah blah blah\n";
}
however, i would like to be able to use cout as one of those streams, so that with this function i could print to a file, cerr, or cout. unfortunatly i have not been able to figure this out.
also, say, o was a flag, in case i couldn't use cout, is there a way to pass an output stream that is null?
so that i wouldn't have to pass an output stream?
first off. what exactly is cout?
is it declared ostream?
if so, can i declare a filestream like this:
ostream out;
or is there another way to do that?
i'm guessing if it was an "ostream" or some other type there would be a template. such as ostream<in> or some sort of flag. which would mean that an ifstream would just be a typedef of something declared as ostream<filein> blah blah blah.
if anyone understands what i'm saying and has some insight, it'd be extremely appreciated since no one else seems to know.
thanks in advance.
foo wants to be able to look like this:
void foo (<output stream> s, int o)
{
s << "blah blah blah\n";
}
however, i would like to be able to use cout as one of those streams, so that with this function i could print to a file, cerr, or cout. unfortunatly i have not been able to figure this out.
also, say, o was a flag, in case i couldn't use cout, is there a way to pass an output stream that is null?
so that i wouldn't have to pass an output stream?
first off. what exactly is cout?
is it declared ostream?
if so, can i declare a filestream like this:
ostream out;
or is there another way to do that?
i'm guessing if it was an "ostream" or some other type there would be a template. such as ostream<in> or some sort of flag. which would mean that an ifstream would just be a typedef of something declared as ostream<filein> blah blah blah.
if anyone understands what i'm saying and has some insight, it'd be extremely appreciated since no one else seems to know.
thanks in advance.