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

  1. Newsgroups: comp.lang.c++
  2. Path: sparky!uunet!decwrl!csus.edu!netcom.com!objsys
  3. From: Bob Hathaway <objsys@netcom.com>
  4. Subject: Re: Object What is an OODBMS?
  5. Message-ID: <h_5mdpr.objsys@netcom.com>
  6. Date: Thu, 13 Aug 92 02:08:25 GMT
  7. Organization: Object Systems
  8. References: <RCZ5NS@netmbx.netmbx.de> <BEVAN.92Aug12152127@jaguar.cs.man.ac.uk>
  9. Lines: 36
  10.  
  11. In article <BEVAN.92Aug12152127@jaguar.cs.man.ac.uk> bevan@cs.man.ac.uk (Stephen J Bevan) writes:
  12. >In article <RCZ5NS@netmbx.netmbx.de> jrobie@netmbx.netmbx.de (Jonathan Robie) writes:
  13. >   When we create a new class we frequently want to use code or data 
  14. >   that already exist in another class.  For instance, if we have a class 
  15. >   called LinkedList we might choose to use this when implementing our 
  16. >   stack.  In fact, we might say that a Stack is a LinkedList which also 
  17. >   has the push() and pop() functions.  We can do this directly using a 
  18. >   mechanism called inheritence:
  19. >
  20. >       class Stack : public LinkedList
  21. >       {
  22. >       public:
  23. >       void    push(int i);
  24. >       int    pop();
  25. >       };
  26. >
  27. >   In this example we would call LinkedList the base class and Stack the 
  28. >   derived class.
  29. >
  30. >Is this generally considered good use/example of inheritance?
  31.  
  32. No.  It should be privately inherited in C++ or even contained as
  33. an aggregate member as I believe you suggest below.
  34.  
  35. >I don't think a "Stack is a LinkedList" at all, rather a
  36. >LinkedList is a possible implementation of a Stack.  I'd therefore use
  37. >parametric rather than inclusion polymorphism to represent this (i.e.
  38. >use a template in C++ speak).  Is my preference for parametric rather
  39. >than inclusion polymorphism blinding me to some advantage in the
  40. >above?
  41.  
  42. With generics you lose the inclusion polymorphism of the base class.
  43. Same (recommended) loss with private inheritance though.
  44.  
  45. bob
  46. objsys@netcom.com
  47.