Afficher un message
Vieux 30/06/2008, 12h51   #2
Daniel Kraft
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: How to return stdout from a method ?

barthelemy.von.haller@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
  Réponse avec citation
 
Page generated in 0,06227 seconds with 9 queries