home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- 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
- From: maxtal@extro.ucc.su.OZ.AU (John MAX Skaller)
- Subject: Re: operators
- Message-ID: <1993Jan27.142015.16659@ucc.su.OZ.AU>
- Keywords: operators,inheritance
- Sender: news@ucc.su.OZ.AU
- Nntp-Posting-Host: extro.ucc.su.oz.au
- Organization: MAXTAL P/L C/- University Computing Centre, Sydney
- References: <1993Jan21.165621.16704@jussieu.fr> <C197Co.JH4@cs.uiuc.edu>
- Date: Wed, 27 Jan 1993 14:20:15 GMT
- Lines: 31
-
- In article <C197Co.JH4@cs.uiuc.edu> pjl@cs.uiuc.edu (Paul Lucas) writes:
- >In <1993Jan21.165621.16704@jussieu.fr> clerc@gla.ecoledoc.ibp.fr writes:
- >
- >
- >>Id like to express in C++ the fact that operators < <= >= can
- >>be defined using operators > and = (eg: a < b is b > a)
- >>I would use a class MathObj (that would implement < <= >= using > and =)
- >>and derive my classes from it, redifining only the basic operators > and =
- >
- > I assume you meant: "in terms of operators > and =="
- > ^
- >>How can I WRITE that in C++ ? (no template solution please)
- >
- > Make < and == virtual in MathObj.
-
- Paul: it doesnt work. OO cant handle relations.
- There is no way to even declare an abstract relation in C++
- (since it doesn't have garbage collection).
-
- Comparison operators are usually based on static
- type and thus cant be virtual. A solution like the recently
- posted solution for assignment slicing may work: but thats
- even *more* effort than just declaring all the comparisons
- (which the original poster wanted to avoid)
-
-
- --
- ;----------------------------------------------------------------------
- JOHN (MAX) SKALLER, maxtal@extro.ucc.su.oz.au
- Maxtal Pty Ltd, 6 MacKay St ASHFIELD, NSW 2131, AUSTRALIA
- ;------ SCIENTIFIC AND ENGINEERING SOFTWARE ---ph: 2 799 8223 --------
-