home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!know!cass.ma02.bull.com!mips2!news.bbn.com!usc!zaphod.mps.ohio-state.edu!wupost!darwin.sura.net!convex!news.utdallas.edu!corpgate!bnrgate!bnr.co.uk!pipex!demon!trmphrst.demon.co.uk!nikki
- From: nikki@trmphrst.demon.co.uk (Nikki Locke)
- Newsgroups: comp.lang.c++
- Subject: Re: Squares and Rectangles (Re: Const Inheritance)
- Message-ID: <721507350snx@trmphrst.demon.co.uk>
- Date: 11 Nov 92 11:42:30 GMT
- Sender: usenet@gate.demon.co.uk
- Reply-To: nikki@trmphrst.demon.co.uk
- Organization: Trumphurst Ltd.
- Lines: 30
- X-Mailer: cppnews $Revision: 1.20 $
-
- In article <1992Nov4.165028.1273@wam.umd.edu> krc@wam.umd.edu (Kevin R. Coombes) writes:
- > From a mathematical point of view, there is no question about the
- > relationship that should hold. Every rectangle IS-A polygon, with
- > four sides and four right angles. Every square IS-A rectangle with
- > four equal sides. If we are using classes Rectangle and Square to
- > model these mathematical concepts (and, say, displaying them on screen),
- > then there certainly are common operations we want to carry out.
- > For example, we would probably like to draw them, move them, intersect
- > them, ....
- I have been trying to avoid the temptation to get into this discussion,
- but I have finally succumbed :-)
-
- The common operations (between Rectangle and Square) you mention also
- apply to other Shapes. I have seen no example so far of an operation
- common to a Square and a Rectangle which is not also common to any Shape
- (or, at least, to some set of shapes which contains Rectangles, Squares
- and others).
-
- I think our problem here is that we have two separate meanings of "is-a".
- In the geometrical sense, any particular Square "is-a" Rectangle. But,
- geometrically, the shape of any given object is fixed, so setWidth() and
- setHeight() methods do not make sense geometrically. If you make all
- objects of fixed size and shape, then a Square is-indeed-a Rectangle.
-
- If you consider the problem from the point of view of a topologist, a
- Square, a Rectangle and a Circle are indistinguishable !
-
- --
- Nikki Locke,Trumphurst Ltd.(PC and Unix consultancy) nikki@trmphrst.demon.co.uk
- trmphrst.demon.co.uk is NOT affiliated with ANY other sites at demon.co.uk.
-