home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!decwrl!csus.edu!netcom.com!objsys
- From: Bob Hathaway <objsys@netcom.com>
- Subject: Re: Object What is an OODBMS?
- Message-ID: <h_5mdpr.objsys@netcom.com>
- Date: Thu, 13 Aug 92 02:08:25 GMT
- Organization: Object Systems
- References: <RCZ5NS@netmbx.netmbx.de> <BEVAN.92Aug12152127@jaguar.cs.man.ac.uk>
- Lines: 36
-
- In article <BEVAN.92Aug12152127@jaguar.cs.man.ac.uk> 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?
-
- No. It should be privately inherited in C++ or even contained as
- an aggregate member as I believe you suggest below.
-
- >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?
-
- With generics you lose the inclusion polymorphism of the base class.
- Same (recommended) loss with private inheritance though.
-
- bob
- objsys@netcom.com
-