home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!zaphod.mps.ohio-state.edu!darwin.sura.net!jvnc.net!nuscc!ntuix!gthkoh
- From: gthkoh@ntuix.ntu.ac.sg (Koh Thong Hwee)
- Subject: Re: BC++ Container Class Problem
- Message-ID: <1992Nov23.073221.15107@ntuix.ntu.ac.sg>
- Organization: Nanyang Technological University - Singapore
- X-Newsreader: TIN [version 1.1 PL7]
- References: <1992Nov16.014419.27027@ntuix.ntu.ac.sg>
- Date: Mon, 23 Nov 1992 07:32:21 GMT
- Lines: 47
-
- Koh Thong Hwee (gthkoh@ntuix.ntu.ac.sg) wrote:
- : ... <other stuff deleted>
- :
- : In particular, I would like to know how to use the link list to store
- : disparate objects. I can use the indirect storage method of storing their
- : pointers instead. However I need to declare the type T for the link list
- : template class and how do I declare it for storing the different pointer types
- : to the many different kinds of objects?
- :
-
- Thanx to all those who replied, in particular, to Ed Barton & Lee Sailer.
-
- You are right in that these disparate objects do share something in common.
- I have look through the disparate objects that are to go to the link list
- and I can group them into 2 classes. These 2 base classes do not have common
- traits between them except that they are used together in a common process.
- So it seems that all my disparate objects will have to be derived from them.
- In that case I will probably need 2 link lists then.
-
- On the other hand, maybe I can still tie them together by abstracting from
- them a "ProcessID" to create the topmost base class. But how useful is
- this? Considering that other than this ProcessID data member in this base
- class, there is no other common data or function members. Any pointer
- from this base class, TBase*, will not be able to access the other members
- from the next lower derived classes which have more members that I need
- access to. Furthermore I cannot convert the base pointer to that of any
- of the 2 lower-level derived classes, even by explicit typecasting:
-
- TBase* ptrBaseClass;
- (TDerived*)ptrBaseClass -> DerivedClass_fn(); //not legal is it?
-
- ( TBase -----> TDerived
- { { ...
- ... DerivedClass_fn();
- } ...
- }
- )
-
- So it seems that I should stick to the first option of 2 base classes
- with 2 link lists...
-
- Any comment on this?
-
-
- TH Koh
- gthkoh@ntuix.ntu.ac.sg
-
-