home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!usc!zaphod.mps.ohio-state.edu!darwin.sura.net!Sirius.dfn.de!zrz.tu-berlin.de!news.netmbx.de!netmbx!jrobie
- From: jrobie@netmbx.netmbx.de (Jonathan Robie)
- Subject: Re: Object What is an OODBMS?
- Organization: netmbx, Berlin, Germany
- Date: Thu, 13 Aug 1992 07:34:32 GMT
- Message-ID: <NH15WIN@netmbx.netmbx.de>
- References: <RCZ5NS@netmbx.netmbx.de> <BEVAN.92Aug12152127@jaguar.cs.man.ac.uk>
- Lines: 52
-
- bevan@cs.man.ac.uk (Stephen J Bevan) writes:
-
- >In article <RCZ5NS@netmbx.netmbx.de> jrobie@netmbx.netmbx.de (Jonathan Robie) writes:
- > When we create a new class we frequently want to use code or data
- > that already exist in another class. For instance, if we have a class
- > called LinkedList we might choose to use this when implementing our
- > stack. In fact, we might say that a Stack is a LinkedList which also
- > has the push() and pop() functions. We can do this directly using a
- > mechanism called inheritence:
-
- > class Stack : public LinkedList
- > {
- > public:
- > void push(int i);
- > int pop();
- > };
-
- > In this example we would call LinkedList the base class and Stack the
- > derived class.
-
- >Is this generally considered good use/example of inheritance?
- >I don't think a "Stack is a LinkedList" at all, rather a
- >LinkedList is a possible implementation of a Stack. I'd therefore use
- >parametric rather than inclusion polymorphism to represent this (i.e.
- >use a template in C++ speak). Is my preference for parametric rather
- >than inclusion polymorphism blinding me to some advantage in the
- >above?
-
- I think you are right. I should have used private inheritance above
- to hide the linked-list implementation details from the user. After
- all, the user could start using LinkedList methods, which would then
- make it impossible for me to change the implementation later without
- affecting the user.
-
-
-
- Jonathan
-
- =======================================================================
-
- Jonathan Robie jrobie@netmbx.UUCP
- Arnold-Zweig-Str. 44 jrobie@netmbx.in-berlin.de
- O-1100 Berlin
- Deutschland Phone: +37 (2) 472 04 19 (Home, East Berlin)
- +49 (30) 342 30 66 (Work, West Berlin)
-
-
- --
- Jonathan
-
- ===========================================================================
-
-