namespace ValueType {
enum Enum {
Boolean = 0,
Float = 1,
Double,
SInt = 8,
SLong,
UInt = SInt + (1 <<4),
ULong = SLong + (1 << 4)
};
}
The body of an enum type declaration defines zero or more enum members, which are the named constants of the enum type. No two enum members can have the same name.
A literal enum member is a constant enum member with no initialized value, or with values that are initialized to. any string literal (e.g. "foo", "bar, "baz") any numeric literal (e.g. 1, 100) a unary minus applied to any numeric literal (e.g. -1, -100)
If the declaration of the enum member has no initializer, its associated value is set implicitly, as follows: 1 If the enum member is the first enum member declared in the enum type, its associated value is zero. 2 Otherwise, the associated value of the enum member is obtained by increasing the associated value of the textually... More ...
An enum declaration may explicitly declare an underlying type of byte, sbyte, short, ushort, int, uint, long or ulong. Note that char cannot be used as an underlying type.
Yes -- the requirement is that it's an integral constant expression. The C++ standard includes the following example:
enum { d, e, f=e+2 };
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With