Somehow I never noticed until today that C++ supports nested classes. This surprised me because when I was learning C++ back in the '90s, I specifically remember nested classes being something that 开发者_如何学GoObject Pascal and Java had, but which C++ did not. I asked an old programmer friend about it and he concurred that he recalls C++ not having nested classes.
Is my recollection of C++ not having nested classes mistaken, or were they actually added to the standard at some point in the past fifteen years? I tried searching Google for information on this topic and I haven't come up with anything helpful yet.
It could also be that I'm thinking of nested functions, which Pascal certainly supports but C does not.
According to "A History of C++: 1979−1991" by Bjarne Stroustrup
Later, after many technical problems and much discontent from users, nested class scopes were re−introduced into C++ in 1989 [Ellis,1990].
see page 28 in http://www.research.att.com/~bs/hopl2.pdf
Nested classes were added in CFront 3.0, released in 1993.
EDIT It goes back even earlier, as you can see in the table of contents to The Annotated C++ Reference Manual (1990).
were they actually added to the standard at some point in the past fifteen years?
C++ was first standardised in 1998 and this standard included nested classes in section 9.7. Since your talking early 90s in your question it is quite possible that whatever particular compiler you were using at the time did not provide support for them.
So Nested Classe were officially supported from 1998 onwards but could have been available (depending on your compiler) at any time prior to this, as alluded to in the answer from Ken Bloom.
精彩评论