home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!ukma!wupost!uwm.edu!ux1.cso.uiuc.edu!cs.uiuc.edu!sparc0b!pjl
- From: pjl@cs.uiuc.edu (Paul Lucas)
- Subject: Re: HELP: Trouble redefining <<
- Message-ID: <BxvtAA.CLr@cs.uiuc.edu>
- Sender: news@cs.uiuc.edu
- Organization: University of Illinois at Urbana-Champaign
- References: <1992Nov17.162531.23815@cc.gatech.edu>
- Distribution: usa
- Date: Tue, 17 Nov 1992 22:32:34 GMT
- Lines: 24
-
- In <1992Nov17.162531.23815@cc.gatech.edu> brianm@cc.gatech.edu (Brian N. Miller) writes:
-
- >Hello, i'm working on a C++ PostScript generator.
-
- >I want to redefine the << operator for a class derived from ostream such that
- >it appends a ' ' after outputting any int.
-
- >BROKEN CODE (Help me fix it...)
- >-----------------------------------------
- >class ps : private ostream {};
-
- >ps &operator<< (ps &x, int i) { return (ps&) (ps ostream::<< i << ' '); }
- >-----------------------------------------
-
- ps_stream& operator<<( int i ) {
- return ostream::operator<<( i ) << ' ';
- }
-
- You don't need and ps& argument (just look at the declaration for
- ostream::operator<<().
- --
- - Paul J. Lucas University of Illinois
- AT&T Bell Laboratories at Urbana-Champaign
- Naperville, IL pjl@cs.uiuc.edu
-