home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / lang / cplus / 16189 < prev    next >
Encoding:
Internet Message Format  |  1992-11-13  |  2.2 KB

  1. 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
  2. From: nikki@trmphrst.demon.co.uk (Nikki Locke)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Squares and Rectangles (Re: Const Inheritance)
  5. Message-ID: <721507350snx@trmphrst.demon.co.uk>
  6. Date: 11 Nov 92 11:42:30 GMT
  7. Sender: usenet@gate.demon.co.uk
  8. Reply-To: nikki@trmphrst.demon.co.uk
  9. Organization: Trumphurst Ltd.
  10. Lines: 30
  11. X-Mailer: cppnews $Revision: 1.20 $
  12.  
  13. In article <1992Nov4.165028.1273@wam.umd.edu> krc@wam.umd.edu (Kevin R. Coombes) writes:
  14. > From a mathematical point of view, there is no question about the
  15. > relationship that should hold. Every rectangle IS-A polygon, with
  16. > four sides and four right angles. Every square IS-A rectangle with
  17. > four equal sides. If we are using classes Rectangle and Square to
  18. > model these mathematical concepts (and, say, displaying them on screen),
  19. > then there certainly are common operations we want to carry out.
  20. > For example, we would probably like to draw them, move them, intersect
  21. > them, .... 
  22. I have been trying to avoid the temptation to get into this discussion, 
  23. but I have finally succumbed :-)
  24.  
  25. The common operations (between Rectangle and Square) you mention also 
  26. apply to other Shapes. I have seen no example so far of an operation
  27. common to a Square and a Rectangle which is not also common to any Shape
  28. (or, at least, to some set of shapes which contains Rectangles, Squares 
  29. and others).
  30.  
  31. I think our problem here is that we have two separate meanings of "is-a".
  32. In the geometrical sense, any particular Square "is-a" Rectangle. But, 
  33. geometrically, the shape of any given object is fixed, so setWidth() and
  34. setHeight() methods do not make sense geometrically. If you make all 
  35. objects of fixed size and shape, then a Square is-indeed-a Rectangle.
  36.  
  37. If you consider the problem from the point of view of a topologist, a 
  38. Square, a Rectangle and a Circle are indistinguishable !
  39.  
  40. -- 
  41. Nikki Locke,Trumphurst Ltd.(PC and Unix consultancy) nikki@trmphrst.demon.co.uk
  42. trmphrst.demon.co.uk is NOT affiliated with ANY other sites at demon.co.uk.
  43.