home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!mcsun!sunic!dkuug!daimi!olm
- From: olm@daimi.aau.dk (Ole Lehrmann Madsen)
- Subject: Re: Nested Classes vs. Class Specialization
- Message-ID: <1992Nov12.073307.4496@daimi.aau.dk>
- Sender: olm@daimi.aau.dk (Ole Lehrmann Madsen)
- Organization: DAIMI: Computer Science Department, Aarhus University, Denmark
- References: <1992Nov11.102816.1@happy.colorado.edu>
- Date: Thu, 12 Nov 92 07:33:07 GMT
- Lines: 79
-
- I have tried to send the following directly to Sieg, but the e-mail
- bounches back. Excuse me for posting it directly here.
- ---olm
-
-
- In comp.lang.c++ you write:
-
-
- >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
-
- Your observation about the problems in combining nested classes
- and inheritance seems very interesting. Since I am not an expert
- in C++ details I am not able to 'confirm your observation'.
-
- In BETA we have for many years used nested classes in combination
- with inheritance. This works quite well and is very useful.
- Nested classes in BETA is, however, more general than in C++,
- since a nested class in BETA can refer to variables in the enclosing
- object. This is far as I know not possible in C++.
-
- Instead of templates we have 'virtual classes' (not the same as virtual
- class in C++)
-
- If you are interested in the BETA solution, I can refer you to
-
- 1. O.L. Madsen: Block Structure in OOLs. In Shriver & Wegner,
- Reserarch directions in OO, MIT Press 1987.
-
- 2. O.L. Madsen, B. Moller-Pedersen: Virtual classes, a powerful
- feature in OOP. OOPSLA 89
-
- 3.O.L. Madsen, B. Magnusson, B. Moller-Pedersen: Strong typing
- of OOLS revisited, OOPSLA 90
-
- If you dont have access to these papers I can mail them. I can also
- mail a preprint of a book on BETA to published by Addison Wesley next spring.
-
- I am very interested in hearing what you find out about your 'observation'.
- I think nested classes is a very poverful feature in combination with
- inheritance.
-
- Sincerely
-
- Ole Lehrmann Madsen
- Computer Science Department
- Aarhus University
- Ny Munkegade
- DK-8000 Aarhus C, DENMARK
- Tel.: +45 86 12 71 88
- Fax.: +45 86 13 57 25
- E-mail: olmadsen@daimi.aau.dk
-
-
-
-