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

  1. Xref: sparky comp.lang.c++:12282 comp.object:3188 comp.databases:6081
  2. Path: sparky!uunet!mcsun!uknet!mucs!m1!bevan
  3. From: bevan@cs.man.ac.uk (Stephen J Bevan)
  4. Newsgroups: comp.lang.c++,comp.object,comp.databases
  5. Subject: Re: Object What is an OODBMS?
  6. Message-ID: <BEVAN.92Aug12152127@jaguar.cs.man.ac.uk>
  7. Date: 12 Aug 92 14:21:27 GMT
  8. References: <RCZ5NS@netmbx.netmbx.de>
  9. Sender: news@cs.man.ac.uk
  10. Followup-To: comp.lang.c++
  11. Organization: Department of Computer Science, University of Manchester
  12. Lines: 27
  13. In-reply-to: jrobie@netmbx.netmbx.de's message of 12 Aug 92 07:02:30 GMT
  14.  
  15. In article <RCZ5NS@netmbx.netmbx.de> jrobie@netmbx.netmbx.de (Jonathan Robie) writes:
  16.    When we create a new class we frequently want to use code or data 
  17.    that already exist in another class.  For instance, if we have a class 
  18.    called LinkedList we might choose to use this when implementing our 
  19.    stack.  In fact, we might say that a Stack is a LinkedList which also 
  20.    has the push() and pop() functions.  We can do this directly using a 
  21.    mechanism called inheritence:
  22.  
  23.        class Stack : public LinkedList
  24.        {
  25.        public:
  26.        void    push(int i);
  27.        int    pop();
  28.        };
  29.  
  30.    In this example we would call LinkedList the base class and Stack the 
  31.    derived class.
  32.  
  33. Is this generally considered good use/example of inheritance?
  34. I don't think a "Stack is a LinkedList" at all, rather a
  35. LinkedList is a possible implementation of a Stack.  I'd therefore use
  36. parametric rather than inclusion polymorphism to represent this (i.e.
  37. use a template in C++ speak).  Is my preference for parametric rather
  38. than inclusion polymorphism blinding me to some advantage in the
  39. above?
  40.  
  41. bevan
  42.