Home

On Sep 27, 12:16 pm, Pete Becker <p...@versatilecoding.com> wrote:
> On 2007-09-27 12:04:48 -0400, aaragon <alejandro.ara...@gmail.com> said:
>
>
>
> > Well, I actually defined operator<< as a template function that could
> > take an ostream or a ofstream. Thus, I can output to screen using cout
> > and output to a file using an ofstream with the same code. I will
> > declare the constructor as explicit. Thank you guys for all your
> > answers! They're very appreciated.
>
> Making the constructor explicit treats the symptom, but not the
> problem. To be able to write to an ofstream as well as to cout, write
> an inserter that takes an ostream&. That's what all the standard
> inserters do (well, actually, they're templates, and they take an
> appropriate instantiation of basic_ostream).
>
> --
> Pete
> Roundhouse Consulting, Ltd. (www.versatilecoding.com) Author of "The
> Standard C++ Library Extensions: a Tutorial and Reference
> (www.petebecker.com/tr1book)

Could you expand on the inserter subject? or give me a link where I
can read about it? Thank you.

previous
next

Re: Fast socket write
Re: help on std::vector
Re: Enums
Re: help understanding iterators with vector::insert
Re: Something in the function tutorial confused me.
Akogo
Dzieci Niczyje
Mam Marzenie
Fundacja Iskierka
Fundacja Hobbit