Sender: maeder AT dhcppc3 Newsgroups: comp.os.msdos.djgpp,gnu.g++.help Subject: Re: ofstream and rdbuf() References: From: Thomas Maeder Date: 19 Dec 2002 20:00:43 +0100 Message-ID: Lines: 36 User-Agent: Gnus/5.0808 (Gnus v5.8.8) XEmacs/21.4 (Military Intelligence) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii NNTP-Posting-Host: 80.218.15.133 X-Trace: news.swissonline.ch 1040324438 80.218.15.133 (19 Dec 2002 20:00:38 +0100) X-Complaints-To: abuse AT swissonline DOT ch To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com "Alex Vinokur" 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 > #include > #include > 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); and static_cast(file1).rdbuf(psbuf_cout);