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

  1. Newsgroups: comp.lang.c++
  2. Path: sparky!uunet!news.univie.ac.at!scsing.switch.ch!univ-lyon1.fr!ghost.dsi.unimi.it!rpi!usc!howland.reston.ans.net!bogus.sura.net!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: <1993Jan27.142015.16659@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> <C197Co.JH4@cs.uiuc.edu>
  11. Date: Wed, 27 Jan 1993 14:20:15 GMT
  12. Lines: 31
  13.  
  14. In article <C197Co.JH4@cs.uiuc.edu> pjl@cs.uiuc.edu (Paul Lucas) writes:
  15. >In <1993Jan21.165621.16704@jussieu.fr> clerc@gla.ecoledoc.ibp.fr writes:
  16. >
  17. >
  18. >>Id like to express in C++ the fact that operators < <= >= can
  19. >>be defined using operators > and = (eg: a < b  is b > a)
  20. >>I would use a class MathObj (that would implement < <= >= using > and =)
  21. >>and derive my classes from it, redifining only the basic operators > and =
  22. >
  23. >    I assume you meant: "in terms of operators > and =="
  24. >                              ^
  25. >>How can I WRITE that in C++ ? (no template solution please)
  26. >
  27. >    Make < and == virtual in MathObj.
  28.  
  29.     Paul: it doesnt work. OO cant handle relations.
  30. There is no way to even declare an abstract relation in C++
  31. (since it doesn't have garbage collection).
  32.  
  33.     Comparison operators are usually based on static
  34. type and thus cant be virtual. A solution like the recently
  35. posted solution for assignment slicing may work: but thats
  36. even *more* effort than just declaring all the comparisons
  37. (which the original poster wanted to avoid)
  38.  
  39.  
  40. -- 
  41. ;----------------------------------------------------------------------
  42.         JOHN (MAX) SKALLER,         maxtal@extro.ucc.su.oz.au
  43.     Maxtal Pty Ltd, 6 MacKay St ASHFIELD, NSW 2131, AUSTRALIA
  44. ;------ SCIENTIFIC AND ENGINEERING SOFTWARE ---ph:  2 799 8223 --------
  45.