On Jun 30, 8:29 am, barthelemy.von.hal...@gmail.com wrote:
> On 30 juin, 12:51, Daniel Kraft <d...@domob.eu> wrote:
>
>
>
> > barthelemy.von.hal...@gmail.com wrote:
> > > Hi,
>
> > > I am trying to return the standard output from a method like that :
>
> > > ostream *XXX::GetDebugStream() {
> > > // return debugFile; // I don't want that, but it works
> > > // return stdout; // this returns : error: cannot convert
> > > `_IO_FILE*' to `std:
stream*' in return
> > > // return cout; // this returns : invalid conversion from
> > > `void*' to `std:
stream*'
> > > }
>
> > > I tried to return stdout or cout but it doesn't work. I understand why
> > > it doesn't work with cout but not with stdout.
>
> > try
> > return &cout;
>
> > cout is not a pointer, thus you will have to take the address of it; and
> > stdout is not a C++ ostream class but rather a FILE* you can use with
> > fprintf and friends.
>
> > Daniel
>
> > > Could someone explain me what I am doing wrong ?
>
> > > Thanks in advance
>
> > > Barth
>
> > --
> > Done: Bar-Sam-Val-Wiz, Dwa-Elf-Hum-Orc, Cha-Law, Fem-Mal
> > Underway: Ran-Gno-Neu-Fem
> > To go: Arc-Cav-Hea-Kni-Mon-Pri-Rog-Tou
>
> Thank you very much, it works. I don't know why I was so sure that
> cout was a pointer...
>
> Barth
Did you tried returning the reference, instead of a pointer?
Just like the << operator?
std:

stream& getDebugStream()
{
return std::cout;
}