home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / std / cplus / 1164 < prev    next >
Encoding:
Text File  |  1992-09-12  |  942 b   |  36 lines

  1. Newsgroups: comp.std.c++
  2. Path: sparky!uunet!world!tob
  3. From: tob@world.std.com (Tom O Breton)
  4. Subject: Re: Answers on a postcard
  5. Message-ID: <BuH6sK.54r@world.std.com>
  6. Organization: The World Public Access UNIX, Brookline, MA
  7. References: <92255.154216KKEYTE@ESOC.BITNET>
  8. Date: Sat, 12 Sep 1992 17:19:31 GMT
  9. Lines: 25
  10.  
  11. Karl:
  12.  
  13. > If not, I would ask: How does one overload the comma operator while
  14. > maintaining its attibutes as an operator?
  15.  
  16.  
  17. It's of dubious usefulness but it can be done:
  18.  
  19. class thisclass
  20. { int&  operator,(int a); }
  21.  
  22. //To call this:  (thisclass)X, (int)Y ... (outside of arg-lists, of course)
  23.   
  24. This will return you an int, just as if the default comma operator had
  25. executed.
  26.  
  27.  
  28. In general, chain operators by returning references (Usually to the same
  29. argument they took).
  30.  
  31.         Tom
  32.  
  33. -- 
  34. The Tom spreads its huge, scaly wings and soars into the wild sky...      
  35. up...       up...     out of sight...   (tob@world.std.com)
  36.