home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / lang / cplus / 19990 < prev    next >
Encoding:
Text File  |  1993-01-28  |  1.4 KB  |  37 lines

  1. Newsgroups: comp.lang.c++
  2. Path: sparky!uunet!charon.amdahl.com!pacbell.com!ames!saimiri.primate.wisc.edu!zaphod.mps.ohio-state.edu!darwin.sura.net!sgiblab!munnari.oz.au!metro!extro.ucc.su.OZ.AU!maxtal
  3. From: maxtal@extro.ucc.su.OZ.AU (John MAX Skaller)
  4. Subject: Re: operators
  5. Message-ID: <1993Jan26.214741.2681@ucc.su.OZ.AU>
  6. Keywords: operators,inheritance
  7. Sender: news@ucc.su.OZ.AU
  8. Nntp-Posting-Host: extro.ucc.su.oz.au
  9. Organization: MAXTAL P/L C/- University Computing Centre, Sydney
  10. References: <1993Jan21.165621.16704@jussieu.fr>
  11. Date: Tue, 26 Jan 1993 21:47:41 GMT
  12. Lines: 23
  13.  
  14. In article <1993Jan21.165621.16704@jussieu.fr> clerc@gla.ecoledoc.ibp.fr writes:
  15. >
  16. >Id like to express in C++ the fact that operators < <= >= can
  17. >be defined using operators > and = (eg: a < b  is b > a)
  18. >I would use a class MathObj (that would implement < <= >= using > and =)
  19. >and derive my classes from it, redifining only the basic operators > and =
  20. >
  21. >How can I WRITE that in C++ ? (no template solution please)
  22. >
  23.  
  24.     <cry> You cant, well, you can .. using macros.
  25.  
  26.     #define stdcmps(T) \
  27.     friend int operator<=(const T& a, const T& b) \
  28.         { return a<b || a==b; } \
  29.     friend int .....
  30.  
  31.  
  32. -- 
  33. ;----------------------------------------------------------------------
  34.         JOHN (MAX) SKALLER,         maxtal@extro.ucc.su.oz.au
  35.     Maxtal Pty Ltd, 6 MacKay St ASHFIELD, NSW 2131, AUSTRALIA
  36. ;------ SCIENTIFIC AND ENGINEERING SOFTWARE ---ph:  2 799 8223 --------
  37.