home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!boulder!happy.colorado.edu!srheintze
- From: srheintze@happy.colorado.edu
- Subject: Nested Classes vs. Class Specialization
- Message-ID: <1992Nov11.102816.1@happy.colorado.edu>
- Lines: 27
- Sender: news@colorado.edu (The Daily Planet)
- Nntp-Posting-Host: happy.uccs.edu
- Organization: University of Colorado, Boulder
- Date: 11 Nov 92 10:28:16 MDT
- Lines: 27
-
-
- There seems to be a great benefit in using nested classes: less
- chance of name space collision.
-
- For example, if we are creating a List class whose implementation consists
- of a class for a list head and a link or node class, there is merit to
- embedding or nesting the node class inside the List class.
-
- However, suppose we use template classes. Suppose we want to do template class
- specialization as discussed in Stan Lippman's "C++ Primer" 2nd edition. For a
- List class, we probably only want to specialize the node class.
-
- When experimenting with nested template classes on Borland C++ v3.1, I could
- not figure out how to use nested template classes with specialization without
- respecifying the entire List class. This, of course, defeats the purpose of
- template class specialization.
-
- I therefore conclude that it is impossible to get the best of both worlds.
- For non-template classes, we want nested class but for template classes that
- might be specialized, we do not want nested classes.
-
- Can someone confirm this observation? Can someone figure out how to do
- template class specialization of a Node class nested inside a List class
- without respecifying the entire List Class?
-
- Thanks,
- Sieg
-