home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / lang / cplus / 16143 < prev    next >
Encoding:
Text File  |  1992-11-11  |  3.2 KB  |  91 lines

  1. Newsgroups: comp.lang.c++
  2. Path: sparky!uunet!mcsun!sunic!dkuug!daimi!olm
  3. From: olm@daimi.aau.dk (Ole Lehrmann Madsen)
  4. Subject: Re: Nested Classes vs. Class Specialization
  5. Message-ID: <1992Nov12.073307.4496@daimi.aau.dk>
  6. Sender: olm@daimi.aau.dk (Ole Lehrmann Madsen)
  7. Organization: DAIMI: Computer Science Department, Aarhus University, Denmark
  8. References: <1992Nov11.102816.1@happy.colorado.edu>
  9. Date: Thu, 12 Nov 92 07:33:07 GMT
  10. Lines: 79
  11.  
  12. I have tried to send the following directly to Sieg, but the e-mail 
  13. bounches back. Excuse me for posting it directly here.
  14. ---olm
  15.  
  16.  
  17. In comp.lang.c++ you write:
  18.  
  19.  
  20. >There seems to be a great benefit in using nested classes:  less
  21. >chance of name space collision.
  22.  
  23. >For example, if we are creating a List class whose implementation consists
  24. >of a class for a list head and a link or node class, there is merit to 
  25. >embedding or nesting the node class inside the List class.
  26.  
  27. >However, suppose we use template classes.  Suppose we want to do template class
  28. >specialization as discussed in Stan Lippman's "C++ Primer" 2nd edition. For a
  29. >List class, we probably only want to  specialize the node class.
  30.  
  31. >When experimenting with nested template classes on Borland C++ v3.1, I could
  32. >not figure out how to use nested template classes with specialization without
  33. >respecifying the entire List class. This, of course, defeats the purpose of
  34. >template class specialization.
  35.  
  36. >I therefore conclude that it is impossible to get the best of both worlds.
  37. >For non-template classes, we want nested class but for template classes that
  38. >might be specialized, we do not want nested classes.
  39.  
  40. >Can someone confirm this observation? Can someone figure out how to do 
  41. >template class specialization of a Node class nested inside a List class
  42. >without respecifying the entire List Class?
  43.  
  44. >            Thanks,
  45. >                    Sieg
  46.  
  47. Your observation about the problems in combining nested classes 
  48. and inheritance seems very interesting. Since I am not an expert
  49. in C++ details I am  not able to 'confirm your observation'.
  50.  
  51. In BETA we have for many years used nested classes in combination
  52. with inheritance. This works quite well and is very useful.
  53. Nested classes in BETA is, however, more general than in C++,
  54. since a nested class in BETA can refer to variables in the enclosing
  55. object. This is far as I know not possible  in C++.
  56.  
  57. Instead of templates we have 'virtual classes' (not the same as virtual
  58. class in C++)
  59.  
  60. If you are interested in the BETA solution, I can refer you to
  61.  
  62.     1. O.L. Madsen: Block Structure in OOLs. In Shriver & Wegner,
  63.       Reserarch directions in OO, MIT Press 1987.
  64.  
  65.     2. O.L. Madsen, B. Moller-Pedersen: Virtual classes, a powerful
  66.        feature in OOP. OOPSLA 89
  67.  
  68.     3.O.L. Madsen, B. Magnusson, B. Moller-Pedersen: Strong typing
  69.       of OOLS revisited, OOPSLA 90
  70.  
  71. If you dont have access to these papers I can mail them. I can also
  72. mail a preprint of a book on BETA to published by Addison Wesley next spring.
  73.  
  74. I am very interested in hearing what you find out about your 'observation'.
  75. I think nested classes is a very poverful feature in combination with
  76. inheritance. 
  77.  
  78. Sincerely
  79.  
  80. Ole Lehrmann Madsen
  81. Computer Science Department
  82. Aarhus University
  83. Ny Munkegade
  84. DK-8000 Aarhus C, DENMARK
  85. Tel.: +45 86 12 71 88
  86. Fax.: +45 86 13 57 25
  87. E-mail: olmadsen@daimi.aau.dk
  88.  
  89.  
  90.  
  91.