home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!charon.amdahl.com!pacbell.com!decwrl!sdd.hp.com!caen!sol.ctr.columbia.edu!The-Star.honeywell.com!umn.edu!mmm.serc.3m.com!pwcs!cdsmn!wells
- From: wells@cdsmn.mn.org (Rich Wells)
- Subject: Re: Const Inheritance
- Message-ID: <Bx970t.B72@cdsmn.mn.org>
- Organization: Dicomed, Inc
- X-Newsreader: TIN [version 1.1 PL6]
- References: <2762@devnull.mpd.tandem.com>
- Date: Thu, 5 Nov 1992 17:24:28 GMT
- Lines: 34
-
- Duane Voth (duanev@devnull.mpd.tandem.com) wrote:
- : frank@Cookie.secapl.com (Frank Adams) writes:
- : >The idea comes from one of the standard examples of an inheritance
- : >hierarchy: shapes. Assume we have a class Shape, with a subclass
- : >Rectangle, and we want to add Square as a class. It seems logical that
- : >Square should be a subclass of Rectangle.
-
- Let us not confuse "subset" with "subclass". "Subclass" is a concept
- we use for implementation; it need not correspond directly to the
- "subset" and "superset" concepts we may be modeling.
-
- So: although the set of squares is a subset of the set of rectangles,
- it does not (necessarily) mean that the class "square" should be a
- subset of class "rectangle". Inheritance can be used for both
- genericity AND specialization. In this case, perhaps Square may be
- the immediate subclass of Shape, with Rectangle a more generic
- subclass of Square containing an extra field for the extra degree
- of freedom.
-
- Of course, this leaves us with objects of type Square * which point
- to objects which violate the basic tenets of Squaredom, which is that
- all 4 sides are equal. Therefore....
-
- : Perhaps the common mathematical definition of a square has led to
- : this delema. Sounds as if, in this instance, there are more differences
- : between a square and a rectangle than there are similarities.
- : Would making class Square and class Rectangle peers of each other
- : cause so much duplication that the simplicity is unwaranted?
-
- No. That is, Yes they may as well be peers. The differences far
- outweigh the similarities.
- --
-
- Richard Wells wells@cdsmn.mn.org or ...!tcnet!cdsmn!wells
-