home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / lang / cplus / 11463 < prev    next >
Encoding:
Text File  |  1992-07-23  |  2.3 KB  |  53 lines

  1. Newsgroups: comp.lang.c++
  2. Path: sparky!uunet!mole-end!mat
  3. From: mat@uunet.uu.net!mole-end
  4. Subject: Re: Language extensions for run-time type identification
  5. Message-ID: <1992Jul24.063825.1395@uunet.uu.net!mole-end>
  6. Organization: :
  7. References: <14ft2uINNjh4@agate.berkeley.edu> <rmartin.711829160@thor>
  8. Date: Fri, 24 Jul 1992 06:38:25 GMT
  9. Lines: 42
  10.  
  11. In article <rmartin.711829160@thor>, rmartin@thor.Rational.COM (Bob Martin) writes:
  12. > shang@corp.mot.com (David (Lujun) Shang) writes:
  13.  
  14. > |In article <14ft2uINNjh4@agate.berkeley.edu> jbuck@forney.berkeley.edu (Joe  
  15. > |Buck) writes:
  16. > | 
  17. > |> * ... it is trivial to force any class ...  to have a virtual function
  18. > |> * table (simply add a virtual destructor).
  19.  
  20. > |Adding something virtual just for the purpose that has nothing to do with it?
  21.  
  22. > Posh!  Every class should have a virtual destructor.  It is insane not
  23. > to declare the destructor virtual.  There is only one, small,
  24. > exception to this rule, which has to do with structs placed in ROM...
  25.  
  26. I don't quite agree with you, Bob.  Any class for which polymorphic
  27. behavior may be desirable should have a virtual destructor.  Polymoprhic
  28. behavior is not tacked on; it must be designed in.  And there is a use
  29. of classes for which run-time polymorphism makes little sense: classes
  30. that represent quantity, quality, or selection.  Included in this
  31. group are `arithmetic' and `geometric' types like Complex, Point,
  32. Rectangle (or their templatized versions), types representing homogeneous
  33. coordinates, transformations, etc., types which represent qualities in
  34. multidimensional space (e.g. an RGB or CMYK description of a color),
  35. and classes which are used as sophisticated versions of  enum .
  36.  
  37. There's another group of classes for which polymorphic behavior makes
  38. little sense: those that are used to implement or provide data structures
  39. (lists, trees, etc.)
  40.  
  41. Oh, and there's a difference between the classes which have `information'
  42. nature (quantity, quality, selection) and classes which implement data
  43. structures: the former are based in the problem domain and identified in
  44. analysis; the latter are based in the solution (programming) domain and
  45. introduced during design.
  46.  
  47. But that's another pot of pointer stew entirely.
  48. -- 
  49.  (This man's opinions are his own.)
  50.  From mole-end                Mark Terribile
  51.  
  52.  uunet!mole-end!mat, Somewhere in Matawan, NJ
  53.