home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!olivea!gossip.pyramid.com!pyramid!infmx!cshaver
- From: cshaver@informix.com (Craig Shaver)
- Newsgroups: comp.lang.c++
- Subject: Re: Need help implementic data structures of generic objects
- Message-ID: <1992Dec23.212922.10775@informix.com>
- Date: 23 Dec 92 21:29:22 GMT
- References: <1992Dec13.002551.778@informix.com> <1992Dec17.104357.3422@unix.brighton.ac.uk>
- Sender: news@informix.com (Usenet News)
- Organization: Informix Software, Inc.
- Lines: 31
-
- In article <1992Dec17.104357.3422@unix.brighton.ac.uk> je@unix.brighton.ac.uk (John English) writes:
- >cshaver@informix.com (Craig Shaver) writes:
- >: It is obvious to me that you have a virtual function in the base class for
- >: all functions that you need to use when dealing with 'Objects'.
- >:
- >: If you use a function on a class that is only restricted to a certain
- >: sub-tree of your inheritance structure, then you know what you are using,
- >: ergo, you should have used that type instead of 'Object'.
- >
- >Yes, but then you end up migrating a lot of the functionality of your
- >hierarchy into class Object, in much the same way as widely-used data
- >structures end up being global in C.
- >
-
- There should not be much, if any, real code in the base class virtual function.
- You may just want to have an error print out or exception handler to show that
- this function is to be implemented by a subclass. If you can come up with
- generic code, then put it in the base class and share it. The base 'Object'
- at the very top of the tree should have very little functionality. By base
- I mean the top of any tree type hierarchy.
-
- You are right to say that sometimes code sharing in the base class is like using
- globals. It is difficult to achieve and should be well thought out. If it is
- poorly formed code (most likely because of the way the classes have been designed)
- then it will not be used in practice, and sub-classes will reimplement the
- functionality to achieve their goals.
-
-
- --
- Craig Shaver (cshaver@informix.com for now) (415)390-0654 (415)926-6407
- Productivity Group POB 60458 Sunnyvale, CA 94088
-