I used this code:

enum E {
    E1, E2, E3, MaxNum
};

const char * ENames[ MaxNum ] = {
    "E1", "E2", "E3"
};

and had no problem. Now I want to use "modern" enum class. The code now looks like this:

enum class E {
    E1, E2, E3, MaxNum
};

const char * ENames[ E::MaxNum ] = {
    "E1", "E2", "E3"
};

and got an error

error: size of array ‘ENames’ has non-integral type ‘E’

error: too many initializers for ‘const char* [1]’

Q: why enum class does become non-integral in c++11, while usual enum is integral ?

What is a decision of a problem ? How can I declare an array with size, that is one of enumeration in enum class ?

Here - http://ideone.com/SNHTYe - is a simple example.

Thank you.

Edit
Report