home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / lang / cplus / 16747 < prev    next >
Encoding:
Text File  |  1992-11-22  |  2.3 KB  |  54 lines

  1. Newsgroups: comp.lang.c++
  2. Path: sparky!uunet!spool.mu.edu!umn.edu!news
  3. From: burchard@horizon.math.utah.edu (Paul Burchard)
  4. Subject: Re: Multiple Inheritance - Necessary?
  5. Message-ID: <1992Nov23.073400.119@news2.cis.umn.edu>
  6. Sender: news@news2.cis.umn.edu (Usenet News Administration)
  7. Nntp-Posting-Host: dialup-slip-1-35.gw.umn.edu
  8. Organization: University of Minnesota
  9. References: <1ejjcaINN1m5@armory.centerline.com>
  10. Date: Mon, 23 Nov 1992 07:34:00 GMT
  11. Lines: 41
  12.  
  13. > In <By17An.4uH@usenet.ucs.indiana.edu> ezachris@iroquois.ucs.indiana.edu  
  14. writes:
  15. > >A friend of mine who programs in Objective-C argues that multiple  
  16. > >inheritance is unnecessary and complicated. 
  17. > >
  18. > >My Objective-C friend would make a new object "Pencil-with-eraser" that  
  19. > >would declare two objects inside it.
  20. > >
  21. > >     PENCIL-WITH-ERASER
  22. > >        Eraser TheEraser(...);
  23. > >        Pencil ThePencil(...);
  24. > >
  25. > >I think this sounds like hogwash. What do you think?
  26.  
  27. You're both wrong :-).  It should be a subclass of pencil which has-a
  28. eraser.
  29.  
  30. In article <1ejjcaINN1m5@armory.centerline.com> matt@centerline.com (Matt Landau) writes:
  31. > There are other uses of MI for which composition just doesn't provide
  32. > the right kind of abstraction.  Consider a class "Collection" that lets
  33. > you insert, remove, and search for elements.  Objects that are part of
  34. > a collection must have certain attributes that comprise "collectability";
  35. > in C++ these attributes are often expressed as virtual member functions
  36. > used by the Collection class itself when manipulating members of the
  37. > collection.  
  38.  
  39. Organizing "can-do" properties of classes is most appropriately done through
  40. formal message protocols rather than inheritance (even the looser "forest"
  41. model of inheritance).  Of course this requires dynamic binding.
  42.  
  43. Only if the common functionality has significant common code does it make
  44. sense to use multiple inheritance to *implement* the protocol.
  45.  
  46. --
  47. --------------------------------------------------------------------
  48. Paul Burchard    <burchard@geom.umn.edu>
  49. ``I'm still learning how to count backwards from infinity...''
  50. --------------------------------------------------------------------
  51. [Disclaimer: I much prefer Objective-C over C++, because I find dynamic
  52. binding a much bigger win than MI...and because Obj-C is just plain fun!]
  53.