Re: Enum within function, is this standard?

From: Ivan Vecerina (please_use_web_form_at_ivan.vecerina.com)
Date: 11/13/03


Date: Thu, 13 Nov 2003 15:18:46 +0100


"Nils Petter Vaskinn" <no@spam.for.me.invalid> wrote in message
news:pan.2003.11.13.13.25.18.343979@spam.for.me.invalid...
| Is this legal?
|
| // test.cpp
| #include <iostream>
|
| int main() {
| enum {zero,one,two};
| std::cout << zero << " " << one << " " << two << std::endl;
| return 0;
| }

Yes, this is a totally legal anonymous enum declaration.

Structs and classes may be declared within a function
as well (and may also be anonymous).
The only limitation with types that are declared within
a function (rather than at namespace or class scope)
is that they cannot be used as template parameters.

hth - Ivan

-- 
http://ivan.vecerina.com


Relevant Pages

  • Re: Using a Class as parameter
    ... should I create a new file for the enum then? ... > int levelWidth; ... > declaration of CLevel is read. ...
    (microsoft.public.vc.language)
  • Re: __attribute__ ((mode(__byte__)))
    ... int is_A (enum my_enum my_val) ... they're actually of type int. ... An "enum" declaration can be used to declare a series of constants ... without declaring a named type. ...
    (comp.lang.c)
  • Re: p124 K&R
    ... ref the enum from there. ... staying with the "extern" theme. ... Again referenced from foo.c using syntax "extern char token". ... Your extern declaration did not say token was an array. ...
    (comp.lang.c)
  • Re: Case Change By Itself in VBA Code - Help
    ... I have a constant problem with this using Enums. ... Once a while back I questioned the group about the Enum case resetting, ... it will be re-capitalized to whatever the module declaration ... Dim i As Integer ...
    (microsoft.public.access.modulesdaovba)
  • Re: Making Definitions
    ... how I use the declaration in other assemblies then. ... public enum ImageDisplaySize ... There is a called FormViewMode. ... Only if you make it a nested type. ...
    (microsoft.public.dotnet.languages.csharp)