Re: Enum within function, is this standard?
From: Ivan Vecerina (please_use_web_form_at_ivan.vecerina.com)
Date: 11/13/03
- Next message: Ekkehard Morgenstern: "Re: const_cast<>"
- Previous message: d2003xx: "Re: Freeware C++ ?"
- In reply to: Nils Petter Vaskinn: "Enum within function, is this standard?"
- Next in thread: Domenico Andreoli: "Re: Enum within function, is this standard?"
- Reply: Domenico Andreoli: "Re: Enum within function, is this standard?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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
- Next message: Ekkehard Morgenstern: "Re: const_cast<>"
- Previous message: d2003xx: "Re: Freeware C++ ?"
- In reply to: Nils Petter Vaskinn: "Enum within function, is this standard?"
- Next in thread: Domenico Andreoli: "Re: Enum within function, is this standard?"
- Reply: Domenico Andreoli: "Re: Enum within function, is this standard?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|