home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / lang / cplus / 15926 < prev    next >
Encoding:
Text File  |  1992-11-08  |  2.5 KB  |  56 lines

  1. Newsgroups: comp.lang.c++
  2. Path: sparky!uunet!munnari.oz.au!metro!extro.ucc.su.OZ.AU!maxtal
  3. From: maxtal@extro.ucc.su.OZ.AU (John MAX Skaller)
  4. Subject: Re: Const Inheritance
  5. Message-ID: <1992Nov8.030406.15468@ucc.su.OZ.AU>
  6. Sender: news@ucc.su.OZ.AU
  7. Nntp-Posting-Host: extro.ucc.su.oz.au
  8. Organization: MAXTAL P/L C/- University Computing Centre, Sydney
  9. References: <2762@devnull.mpd.tandem.com> <Bx970t.B72@cdsmn.mn.org>
  10. Date: Sun, 8 Nov 1992 03:04:06 GMT
  11. Lines: 43
  12.  
  13. In article <Bx970t.B72@cdsmn.mn.org> wells@cdsmn.mn.org (Rich Wells) writes:
  14. >Duane Voth (duanev@devnull.mpd.tandem.com) wrote:
  15. >: frank@Cookie.secapl.com (Frank Adams) writes:
  16. >: >The idea comes from one of the standard examples of an inheritance
  17. >: >hierarchy: shapes.  Assume we have a class Shape, with a subclass
  18. >: >Rectangle, and we want to add Square as a class.  It seems logical that
  19. >: >Square should be a subclass of Rectangle.
  20. >
  21. >Let us not confuse "subset" with "subclass".  "Subclass" is a concept
  22. >we use for implementation; it need not correspond directly to the
  23. >"subset" and "superset" concepts we may be modeling.
  24.  
  25.     Not my way of seeing it. Subclasses must be subsets, but that
  26. is not enough, mutators on elements of a subclass must yield valid
  27. member of the subclass, i.e. subclasses are subsets closed under
  28. mutation.
  29.  
  30. >
  31. >So: although the set of squares is a subset of the set of rectangles,
  32. >it does not (necessarily) mean that the class "square" should be a
  33. >subset of class "rectangle".  Inheritance can be used for both
  34. >genericity AND specialization.  In this case, perhaps Square may be
  35. >the immediate subclass of Shape, with Rectangle a more generic
  36. >subclass of Square containing an extra field for the extra degree
  37. >of freedom.
  38.  
  39.     In other words, inheritance can be used for other than subclassing.
  40. In particular, inheritance can also be used for composition in a manner
  41. functionally equivalent to inclusion. This is always the case in toto
  42. if the base has no virtual functions, the base could always have
  43. just been included as a member, although you would have to 
  44. export the functions out of it manually.
  45.  
  46.  
  47.     In any case, in the C++ community the words 'derived class'
  48. and 'base class' are used where inheritance is concerned, and
  49. 'subclassing' should be reserved IMHO for a strict IsA relation.
  50.  
  51. -- 
  52. ;----------------------------------------------------------------------
  53.         JOHN (MAX) SKALLER,         maxtal@extro.ucc.su.oz.au
  54.     Maxtal Pty Ltd, 6 MacKay St ASHFIELD, NSW 2131, AUSTRALIA
  55. ;--------------- SCIENTIFIC AND ENGINEERING SOFTWARE ------------------
  56.