home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / lang / cplus / 16432 < prev    next >
Encoding:
Text File  |  1992-11-17  |  879 b   |  26 lines

  1. Newsgroups: comp.lang.c++
  2. Path: sparky!uunet!destroyer!gatech!cc.gatech.edu!cc.gatech.edu!brianm
  3. From: brianm@cc.gatech.edu (Brian N. Miller)
  4. Subject: HELP:  Trouble redefining <<
  5. Message-ID: <1992Nov17.162531.23815@cc.gatech.edu>
  6. Sender: news@cc.gatech.edu
  7. Organization: Georgia Tech College of Computing
  8. Date: Tue, 17 Nov 1992 16:25:31 GMT
  9. Lines: 15
  10.  
  11. Hello, i'm working on a C++ PostScript generator.
  12.  
  13. I want to redefine the << operator for a class derived from ostream such that
  14. it appends a ' ' after outputting any int.
  15.  
  16. BROKEN CODE   (Help me fix it...)
  17. -----------------------------------------
  18. class ps : private ostream {};
  19.  
  20. ps &operator<< (ps &x, int i) { return (ps&) (ps ostream::<< i << ' '); }
  21. -----------------------------------------
  22.  
  23. Needless to say, this code is not even parsable, but i'm sure you
  24. understand my intention.  Any suggestions?
  25. Thanks in advance.
  26.