home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / lang / cplus / 12298 < prev    next >
Encoding:
Text File  |  1992-08-12  |  2.2 KB  |  63 lines

  1. Newsgroups: comp.lang.c++
  2. Path: sparky!uunet!usc!zaphod.mps.ohio-state.edu!darwin.sura.net!Sirius.dfn.de!zrz.tu-berlin.de!news.netmbx.de!netmbx!jrobie
  3. From: jrobie@netmbx.netmbx.de (Jonathan Robie)
  4. Subject: Re: Object What is an OODBMS?
  5. Organization: netmbx, Berlin, Germany
  6. Date: Thu, 13 Aug 1992 07:34:32 GMT
  7. Message-ID: <NH15WIN@netmbx.netmbx.de>
  8. References: <RCZ5NS@netmbx.netmbx.de> <BEVAN.92Aug12152127@jaguar.cs.man.ac.uk>
  9. Lines: 52
  10.  
  11. bevan@cs.man.ac.uk (Stephen J Bevan) writes:
  12.  
  13. >In article <RCZ5NS@netmbx.netmbx.de> jrobie@netmbx.netmbx.de (Jonathan Robie) writes:
  14. >   When we create a new class we frequently want to use code or data 
  15. >   that already exist in another class.  For instance, if we have a class 
  16. >   called LinkedList we might choose to use this when implementing our 
  17. >   stack.  In fact, we might say that a Stack is a LinkedList which also 
  18. >   has the push() and pop() functions.  We can do this directly using a 
  19. >   mechanism called inheritence:
  20.  
  21. >       class Stack : public LinkedList
  22. >       {
  23. >       public:
  24. >       void    push(int i);
  25. >       int    pop();
  26. >       };
  27.  
  28. >   In this example we would call LinkedList the base class and Stack the 
  29. >   derived class.
  30.  
  31. >Is this generally considered good use/example of inheritance?
  32. >I don't think a "Stack is a LinkedList" at all, rather a
  33. >LinkedList is a possible implementation of a Stack.  I'd therefore use
  34. >parametric rather than inclusion polymorphism to represent this (i.e.
  35. >use a template in C++ speak).  Is my preference for parametric rather
  36. >than inclusion polymorphism blinding me to some advantage in the
  37. >above?
  38.  
  39. I think you are right.  I should have used private inheritance above
  40. to hide the linked-list implementation details from the user.  After
  41. all, the user could start using LinkedList methods, which would then
  42. make it impossible for me to change the implementation later without
  43. affecting the user.
  44.  
  45.  
  46.  
  47. Jonathan
  48.  
  49. =======================================================================
  50.  
  51. Jonathan Robie        jrobie@netmbx.UUCP
  52. Arnold-Zweig-Str. 44    jrobie@netmbx.in-berlin.de
  53. O-1100 Berlin        
  54. Deutschland        Phone:  +37 (2) 472 04 19  (Home, East Berlin)
  55.                 +49 (30) 342 30 66 (Work, West Berlin)
  56.  
  57.  
  58. -- 
  59. Jonathan
  60.  
  61. ===========================================================================
  62.  
  63.