| www.delorie.com/archives/browse.cgi | search |
| From: | "Alex Vinokur" <alexvn AT bigfoot DOT com> |
| Newsgroups: | comp.os.msdos.djgpp,gnu.g++.help |
| Subject: | Re: ofstream and rdbuf() |
| Date: | Thu, 19 Dec 2002 22:17:55 +0200 |
| Lines: | 51 |
| Message-ID: | <att9ia$2m0jf$1@ID-79865.news.dfncis.de> |
| References: | <atpq2h$1ef1r$1 AT ID-79865 DOT news DOT dfncis DOT de> <atrmeg$1v1a1$1 AT ID-79865 DOT news DOT dfncis DOT de> <m2fzstg7fo DOT fsf AT glue DOT ch> |
| NNTP-Posting-Host: | pop03-2-ras1-p97.barak.net.il (212.150.97.97) |
| X-Trace: | fu-berlin.de 1040329100 2818671 212.150.97.97 (16 [79865]) |
| X-Priority: | 3 |
| X-MSMail-Priority: | Normal |
| X-Newsreader: | Microsoft Outlook Express 5.50.4522.1200 |
| X-Mimeole: | Produced By Microsoft MimeOLE V5.50.4522.1200 |
| To: | djgpp AT delorie DOT com |
| DJ-Gateway: | from newsgroup comp.os.msdos.djgpp |
| Reply-To: | djgpp AT delorie DOT com |
"Thomas Maeder" <maeder AT glue DOT ch> wrote in message news:m2fzstg7fo DOT fsf AT glue DOT ch...
> "Alex Vinokur" <alexvn AT bigfoot DOT com> writes:
>
> > ===============
> > Windows 2000
> > DJGPP 2.03
> > GNU gcc/gpp 3.1
> > ===============
> >
> >
> > I have got compilation errors related to ofstream and rdbuf().
> > Is there any way to do what I want to ?
>
> A much shorter test program would have been enough ...
>
>
> > #include <iostream>
> > #include <fstream>
> > #include <assert.h>
> > using namespace std;
> >
> > int main ()
> > {
> > streambuf *psbuf_cout;
> > ofstream file1;
> > file1.open ("f1.txt");
> > psbuf_cout = cout.rdbuf();
> > file1.rdbuf(psbuf_cout); // Line#61
>
> There is an overload of rdbuf() in std::ofstream which hides the
> std::ostream::rdbuf() version you attempt to call. Your options include:
>
> file1.std::ostream::rdbuf(psbuf_cout);
Thanks. It works OK.
>
> and
>
> static_cast<std::ostream &>(file1).rdbuf(psbuf_cout);
--
==============================
Alex Vinokur
mailto:alexvn AT go DOT to
http://www.simtel.net/pub/oth/19088.html
==============================
| webmaster | delorie software privacy |
| Copyright © 2019 by DJ Delorie | Updated Jul 2019 |