| delorie.com/archives/browse.cgi | search |
| From: | comeau AT panix DOT com (Greg Comeau) |
| Newsgroups: | comp.os.linux.development.apps,comp.os.msdos.djgpp,comp.unix.programmer |
| Subject: | Re: C++ Passing ostreams by reference to methods, problem |
| Date: | 30 May 1997 15:12:17 -0400 |
| Organization: | Comeau Computing; http://www.comeaucomputing.com |
| Lines: | 40 |
| Message-ID: | <D6526AA85DB70553.5D25D6032E4BAF07.4B06C389D7077A49@library-proxy.airnews.net> |
| References: | <01bc6b49$27fce100$1b2443a1 AT pcoec DOT uclm DOT es> |
| Reply-To: | comeau AT comeaucomputing DOT com |
| NNTP-Proxy-Relay: | library.airnews.net |
| NNTP-Posting-Host: | biceps.gymnet.com |
| To: | djgpp AT delorie DOT com |
| DJ-Gateway: | from newsgroup comp.os.msdos.djgpp |
In article <01bc6b49$27fce100$1b2443a1 AT pcoec DOT uclm DOT es> "Roberto Henríquez Laurent" <shl24634 AT alumnos DOT inf-cr DOT uclm DOT es> writes:
>
> I'm trying to pass a stream to a method as a by-reference parameter so
>that this method could write info to it, in this way:
>
> i've got a class which defines one of its methods as this:
>
> void WriteYourInfo(ofstream &Dest)
> {
> Dest << "This is a test";
> }
>
> And I call the method like this:
>
>
> ofstream fout("myFile");
> .
> .
> .
> myObject.WriteYourInfo(fout);
> .
> .
> .
> fout.close()
>
> It works perfectly under MS-DOS, compiling with DJGPP. Under Linux the
>output goes to stdout instead of going to the file. Both versions of gcc
>are 2.7.2.
> What am I doing wrong? HELP!!!
Does fout get opened properly? Perhaps it doesn't and hence something
funky is happening?
- Greg
--
Comeau Computing, 91-34 120th Street, Richmond Hill, NY, 11418-3214
Producers of Comeau C++ 4.0 front-end pre-release
****WEB: http://www.comeaucomputing.com / Voice:718-945-0009 / Fax:718-441-2310
Here:comeau AT comeaucomputing DOT com / BIX:comeau or comeau AT bix DOT com / CIS:72331,3421
| webmaster | delorie software privacy |
| Copyright © 2019 by DJ Delorie | Updated Jul 2019 |