Class in function scope

Discussion in 'C++' started by zerofighter, May 8, 2005.

  1. zerofighter

    zerofighter Guest

    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?
     
    zerofighter, May 8, 2005
    #1
    1. Advertising

  2. "zerofighter" <> wrote in message
    news:d5kc03$di4$...
    > 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
     
    Ivan Vecerina, May 8, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Paul Opal
    Replies:
    12
    Views:
    1,005
    Paul Opal
    Oct 11, 2004
  2. ann
    Replies:
    13
    Views:
    696
    Patricia Shanahan
    Sep 13, 2005
  3. Steven T. Hatton
    Replies:
    9
    Views:
    520
  4. Xah Lee
    Replies:
    0
    Views:
    2,283
    Xah Lee
    Feb 26, 2009
  5. Andrew Falanga
    Replies:
    2
    Views:
    217
    Andrew Falanga
    Nov 22, 2008
Loading...

Share This Page