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