home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / lang / cplus / 16776 < prev    next >
Encoding:
Internet Message Format  |  1992-11-23  |  2.1 KB

  1. Path: sparky!uunet!news.centerline.com!matt
  2. From: matt@centerline.com (Matt Landau)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Multiple Inheritance - Necessary?
  5. Date: 23 Nov 1992 17:57:15 GMT
  6. Organization: CenterLine Software, Inc.
  7. Lines: 31
  8. Message-ID: <1er61rINN6vr@armory.centerline.com>
  9. References: <1ejjcaINN1m5@armory.centerline.com> <1992Nov23.073400.119@news2.cis.umn.edu>
  10. NNTP-Posting-Host: 140.239.1.32
  11.  
  12. In <1992Nov23.073400.119@news2.cis.umn.edu> burchard@horizon.math.utah.edu (Paul Burchard) writes:
  13. >Organizing "can-do" properties of classes is most appropriately done through
  14. >formal message protocols rather than inheritance (even the looser "forest"
  15. >model of inheritance).  Of course this requires dynamic binding.
  16.  
  17. Yes, but the original discussion question was "Is multiple inheritance 
  18. necessary?" ... the answer is "For certain kinds of operations, yes, at 
  19. least if you're programming in in C++."
  20.  
  21. >Only if the common functionality has significant common code does it make
  22. >sense to use multiple inheritance to *implement* the protocol.
  23.  
  24. That depends on whether the goal is inheritance of interface or inheritance
  25. of implementation.  In the "MI defines mixin attributes" model, the "common
  26. functionality" may not involve ANY common code, which is fine because all
  27. you want to inherit is the interface.
  28.  
  29. When writing operator== for a slew of different classes, all of which you 
  30. wish to endow with the attribute of collectability, it's perfectly possible 
  31. (in fact, it's very common) for the implementations of X::operator== to be 
  32. completely different for every X.  Inheriting from a Collectble class that
  33. defines a pure virtual operator== simply serves to *force* every derived
  34. class to implement the interfaces requires for collectability.  
  35.  
  36. In the extreme case (which is the one I most often use), the attribute
  37. base class contains *no* code whatsoever -- just a bunch of pure virtual
  38. functions.  There are certainly other implementation strategies available
  39. in other languages, but this is C++ we're talking about here.
  40. --
  41.  Matt Landau            Waiting for a flash of enlightenment
  42.  matt@centerline.com              in all this blood and thunder
  43.