home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / lang / cplus / 16749 < prev    next >
Encoding:
Text File  |  1992-11-22  |  2.4 KB  |  59 lines

  1. Newsgroups: comp.lang.c++
  2. Path: sparky!uunet!zaphod.mps.ohio-state.edu!darwin.sura.net!jvnc.net!nuscc!ntuix!gthkoh
  3. From: gthkoh@ntuix.ntu.ac.sg (Koh Thong Hwee)
  4. Subject: Re: BC++ Container Class Problem
  5. Message-ID: <1992Nov23.073221.15107@ntuix.ntu.ac.sg>
  6. Organization: Nanyang Technological University - Singapore
  7. X-Newsreader: TIN [version 1.1 PL7]
  8. References: <1992Nov16.014419.27027@ntuix.ntu.ac.sg>
  9. Date: Mon, 23 Nov 1992 07:32:21 GMT
  10. Lines: 47
  11.  
  12. Koh Thong Hwee (gthkoh@ntuix.ntu.ac.sg) wrote:
  13. :   ... <other stuff deleted>
  14. : In particular, I would like to know how to use the link list to store
  15. : disparate objects.  I can use the indirect storage method of storing their
  16. : pointers instead.  However I need to declare the type T for the link list
  17. : template class and how do I declare it for storing the different pointer types
  18. : to the many different kinds of objects? 
  19.  
  20. Thanx to all those who replied, in particular, to Ed Barton & Lee Sailer.
  21.  
  22. You are right in that these disparate objects do share something in common.
  23. I have look through the disparate objects that are to go to the link list
  24. and I can group them into 2 classes.  These 2 base classes do not have common 
  25. traits between them except that they are used together in a common process.
  26. So it seems that all my disparate objects will have to be derived from them.
  27. In that case I will probably need 2 link lists then.
  28.  
  29. On the other hand, maybe I can still tie them together by abstracting from
  30. them a "ProcessID" to create the topmost base class.  But how useful is 
  31. this?  Considering that other than this ProcessID data member in this base
  32. class, there is no other common data or function members.  Any pointer
  33. from this base class, TBase*, will not be able to access the other members
  34. from the next lower derived classes which have more members that I need
  35. access to.  Furthermore I cannot convert the base pointer to that of any
  36. of the 2 lower-level derived classes, even by explicit typecasting:
  37.  
  38.     TBase*   ptrBaseClass;
  39.     (TDerived*)ptrBaseClass -> DerivedClass_fn();     //not legal is it?
  40.  
  41. (        TBase   ----->   TDerived
  42.          {                {   ...
  43.             ...               DerivedClass_fn();
  44.          }                    ...
  45.                           }
  46. )
  47.  
  48. So it seems that I should stick to the first option of 2 base classes
  49. with 2 link lists...
  50.  
  51. Any comment on this?
  52.  
  53.  
  54. TH Koh
  55. gthkoh@ntuix.ntu.ac.sg
  56.  
  57.