home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!spool.mu.edu!umn.edu!news
- From: burchard@horizon.math.utah.edu (Paul Burchard)
- Subject: Re: Multiple Inheritance - Necessary?
- Message-ID: <1992Nov23.073400.119@news2.cis.umn.edu>
- Sender: news@news2.cis.umn.edu (Usenet News Administration)
- Nntp-Posting-Host: dialup-slip-1-35.gw.umn.edu
- Organization: University of Minnesota
- References: <1ejjcaINN1m5@armory.centerline.com>
- Date: Mon, 23 Nov 1992 07:34:00 GMT
- Lines: 41
-
- > In <By17An.4uH@usenet.ucs.indiana.edu> ezachris@iroquois.ucs.indiana.edu
- writes:
- > >A friend of mine who programs in Objective-C argues that multiple
- > >inheritance is unnecessary and complicated.
- > >
- > >My Objective-C friend would make a new object "Pencil-with-eraser" that
- > >would declare two objects inside it.
- > >
- > > PENCIL-WITH-ERASER
- > > Eraser TheEraser(...);
- > > Pencil ThePencil(...);
- > >
- > >I think this sounds like hogwash. What do you think?
-
- You're both wrong :-). It should be a subclass of pencil which has-a
- eraser.
-
- In article <1ejjcaINN1m5@armory.centerline.com> matt@centerline.com (Matt Landau) writes:
- >
- > There are other uses of MI for which composition just doesn't provide
- > the right kind of abstraction. Consider a class "Collection" that lets
- > you insert, remove, and search for elements. Objects that are part of
- > a collection must have certain attributes that comprise "collectability";
- > in C++ these attributes are often expressed as virtual member functions
- > used by the Collection class itself when manipulating members of the
- > collection.
-
- 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.
-
- Only if the common functionality has significant common code does it make
- sense to use multiple inheritance to *implement* the protocol.
-
- --
- --------------------------------------------------------------------
- Paul Burchard <burchard@geom.umn.edu>
- ``I'm still learning how to count backwards from infinity...''
- --------------------------------------------------------------------
- [Disclaimer: I much prefer Objective-C over C++, because I find dynamic
- binding a much bigger win than MI...and because Obj-C is just plain fun!]
-