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

  1. Newsgroups: comp.lang.c++
  2. Path: sparky!uunet!boulder!happy.colorado.edu!srheintze
  3. From: srheintze@happy.colorado.edu
  4. Subject: Nested Classes vs. Class Specialization
  5. Message-ID: <1992Nov11.102816.1@happy.colorado.edu>
  6. Lines: 27
  7. Sender: news@colorado.edu (The Daily Planet)
  8. Nntp-Posting-Host: happy.uccs.edu
  9. Organization: University of Colorado, Boulder
  10. Date: 11 Nov 92 10:28:16 MDT
  11. Lines: 27
  12.  
  13.  
  14. There seems to be a great benefit in using nested classes:  less
  15. chance of name space collision.
  16.  
  17. For example, if we are creating a List class whose implementation consists
  18. of a class for a list head and a link or node class, there is merit to 
  19. embedding or nesting the node class inside the List class.
  20.  
  21. However, suppose we use template classes.  Suppose we want to do template class
  22. specialization as discussed in Stan Lippman's "C++ Primer" 2nd edition. For a
  23. List class, we probably only want to  specialize the node class.
  24.  
  25. When experimenting with nested template classes on Borland C++ v3.1, I could
  26. not figure out how to use nested template classes with specialization without
  27. respecifying the entire List class. This, of course, defeats the purpose of
  28. template class specialization.
  29.  
  30. I therefore conclude that it is impossible to get the best of both worlds.
  31. For non-template classes, we want nested class but for template classes that
  32. might be specialized, we do not want nested classes.
  33.  
  34. Can someone confirm this observation? Can someone figure out how to do 
  35. template class specialization of a Node class nested inside a List class
  36. without respecifying the entire List Class?
  37.  
  38.             Thanks,
  39.                     Sieg
  40.