home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / lang / cplus / 18044 < prev    next >
Encoding:
Text File  |  1992-12-16  |  2.4 KB  |  59 lines

  1. Newsgroups: comp.lang.c++
  2. Path: sparky!uunet!munnari.oz.au!metro!extro.ucc.su.OZ.AU!timp
  3. From: timp@extro.ucc.su.OZ.AU (Tim Posney)
  4. Subject: Re: Need help implementic data structures of generic objects
  5. Message-ID: <timp.724484167@extro.ucc.su.OZ.AU>
  6. Sender: news@ucc.su.OZ.AU
  7. Nntp-Posting-Host: extro.ucc.su.oz.au
  8. Organization: Sydney University Computing Service, Sydney, NSW, Australia
  9. References: <1992Dec10.114636.16861@ucc.su.OZ.AU> <1992Dec11.233253.27540@informix.com> <MATT.92Dec11162629@physics.berkeley.edu> <1992Dec13.002551.778@informix.com>
  10. Date: Wed, 16 Dec 1992 05:36:07 GMT
  11. Lines: 46
  12.  
  13. cshaver@informix.com (Craig Shaver) writes:
  14.  
  15. [Stuff deleted]
  16.  
  17. >It is obvious to me that you have a virtual function in the base class for 
  18. >all functions that you need to use when dealing with 'Objects'.
  19.  
  20. This is a really poor,
  21. At the time you declare Object you need to come up with all the
  22. functions that an Object will support else you cannot write generic
  23. code, and worst will have to rebuild anything that refereces Object.
  24. Or you will have to downcast Object * things to derived classes.
  25. It is bad form to 'downcast objects',
  26.     i.e. ptr = (Derived_From_Oject *) Object_ptr.
  27.     since you then lose type checking at compile time.
  28.  
  29.  
  30. The obvious solution is to use Templates, it is precisely for this type
  31. of problem that they were developed. They are compile check safe
  32. and do not require extra code.
  33.  
  34. >If you use a function on a class that is only restricted to a certain
  35. >sub-tree of your inheritance structure, then you know what you are using,
  36.                       ********************************
  37. Surely in the OOP world we can write code that will work correctly even
  38. if the user does not know what he is doing. This is the whole point.
  39.     >ergo, you should have used that type instead of 'Object'.
  40. Surely one can write generic container classes that will work on
  41. Objects today, and Mooses tomorrow, without re-coding (even of headers)
  42. and without re-compiling.
  43.  
  44. >Please; in all of the above, correct me if I have been technically
  45. >wrong, and then explain your philisophical counter point to the
  46. >use of inheritance.
  47.  
  48. I agree that inheritance is great but do not use the languague features
  49. incorrectly. Smalltalk and C++ are DIFFERENT, they approach the same
  50. problems differently. What is a good solution in Smalltalk (Object etc)
  51. is a bad solution in C++. It is possible to write completely generic
  52. container classes using templates, and that is the 'correct' solution
  53. for C++
  54.  
  55.  
  56. tim posney
  57.  
  58.  
  59.