"zerofighter" <ze*********@sogou.com> wrote in message
news:d5**********@news.yaako.com...
Today I found I can define a class in a function scope, I use vc7.1. I
remember it will generat a error when compile time in vc6.0. Is it a new
feature in vc7.1? Is it a feature of standard C++? Can I compile the code
in GCC?
It is a feature of standard C++ (actually inherited from C, where it was
present). It will work in GCC as well, I even think it would work in VC6.
However, such a class definition currently has limitations. In particular,
it cannot be used to instantiate a template. This makes it impossible to
use such a 'local class' to locally implement the predicate of an STL
algorithm. I would expect that this limitation will be removed in the
next C++ standard.
hth -Ivan
--
http://ivan.vecerina.com/contact/?subject=NG_POST <- email contact form
Brainbench MVP for C++ <>
http://www.brainbench.com