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

  1. Newsgroups: comp.lang.c++
  2. Path: sparky!uunet!zaphod.mps.ohio-state.edu!moe.ksu.ksu.edu!ux1.cso.uiuc.edu!cs.uiuc.edu!sparc0b!pjl
  3. From: pjl@cs.uiuc.edu (Paul Lucas)
  4. Subject: Re: Multiple Inheritance - Necessary?
  5. Message-ID: <By1HqH.21q@cs.uiuc.edu>
  6. Keywords: c++ inheritance
  7. Sender: news@cs.uiuc.edu
  8. Organization: University of Illinois at Urbana-Champaign
  9. References: <By17An.4uH@usenet.ucs.indiana.edu>
  10. Distribution: usa
  11. Date: Sat, 21 Nov 1992 00:08:40 GMT
  12. Lines: 40
  13.  
  14. In <By17An.4uH@usenet.ucs.indiana.edu> ezachris@iroquois.ucs.indiana.edu writes:
  15.  
  16. >A friend of mine who programs in Objective-C argues that multiple  
  17. >inheritance is unnecessary and complicated. 
  18.  
  19. *****>    S/He doesn't _have_ to use it if s/he doesn't understand it.
  20.     It's useful when you need it; useless otherwise.  (This state-
  21.     ment is true of everything.)
  22.  
  23. >Let's say you have a pencil-object and an eraser-object and to create a  
  24. >pencil-with-an-eraser-on-it you'd inherit from both the pencil and the  
  25. >eraser object, right?
  26.  
  27. *****>    I wouldn't (this is a bad example, IMHO).  A pencil-with-eraser
  28.     is-a pencil but it isn't-an eraser.  I would derived pencil-with
  29.     -eraser from pencil that has-an eraser.
  30.  
  31. >My Objective-C friend would make a new object "Pencil-with-eraser" that  
  32. >would declare two objects inside it.
  33.  
  34. >Like this:
  35.  
  36. >     PENCIL-WITH-ERASER
  37. >        Eraser TheEraser(...);
  38. >        Pencil ThePencil(...);
  39.  
  40. >To implement the functionality of the pencil and the eraser he'd write a  
  41. >bunch of functions that call the functions inside the pencil and the  
  42. >eraser objects. 
  43.  
  44. *****>    Then a pencil-with-eraser can not be used in all places a pencil
  45.     can since it's not derived from it.
  46.  
  47. >I think this sounds like hogwash. What do you think?
  48.  
  49. *****>    Hogwash.  MI, like all things, has its place. 
  50. -- 
  51.     - Paul J. Lucas                University of Illinois    
  52.       AT&T Bell Laboratories        at Urbana-Champaign
  53.       Naperville, IL            pjl@cs.uiuc.edu
  54.