home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / gnu / gcc / bug / 2108 < prev    next >
Encoding:
Text File  |  1992-08-12  |  963 b   |  37 lines

  1. Newsgroups: gnu.gcc.bug
  2. Path: sparky!uunet!cis.ohio-state.edu!dcs.ed.ac.UK!ret
  3. From: ret@dcs.ed.ac.UK (Rik)
  4. Subject: Yet another one
  5. Message-ID: <4118.9208112009@garay.dcs.ed.ac.uk>
  6. Sender: gnulists@ai.mit.edu
  7. Organization: GNUs Not Usenet
  8. Distribution: gnu
  9. Date: Tue, 11 Aug 1992 20:09:32 GMT
  10. Approved: bug-gcc@prep.ai.mit.edu
  11. Lines: 24
  12.  
  13. >From Reference manual r.13.4.7  Increment & decrement :
  14.  
  15. class X {
  16.    public: X operator++() { a=2 ; return *this ;} 
  17.            X operator++(int) { a=5 ; return *this ;}
  18.            int a ;
  19. };
  20.  
  21. main () {
  22.    X var ;
  23.    ++var ;
  24.    printf("%d\n",var.a) ;
  25.    var++ ;
  26.    printf("%d\n",var.a) ;
  27. }
  28.  
  29. Prints 2 twice. Replace the postincrement call var++ with var.operator++(0)
  30. and it works.
  31.  
  32. > Richard Eyre-Todd.  Department of Computer Science, University of Edinburgh.
  33.  
  34. > Email: ret@uk.ac.ed.dcs                     | Solid fuel is for camp-fires,
  35. > or     ret%dcs.ed.ac.uk@nsfnet-relay.ac.uk  | not boosting Space Shuttles. :-)
  36.  
  37.