Are C++ enums signed or unsigned?

Let’s go to the source. Here’s what the C++03 standard (ISO/IEC 14882:2003) document says in 7.2-5 (Enumeration declarations):

The underlying type of an enumeration
is an integral type that can represent
all the enumerator values defined in
the enumeration. It is
implementation-defined which integral
type is used as the underlying type
for an enumeration except that the
underlying type shall not be larger
than int unless the value of an
enumerator cannot fit in an int or
unsigned int.

In short, your compiler gets to choose (obviously, if you have negative numbers for some of your ennumeration values, it’ll be signed).

Leave a Comment