Can C++ declare an enumeration type with only 1 byte (or less)?

Enumeration type, which is treated as int or unsigned by default in C++. If there is a negative value in enum, it is regarded as int, otherwise it is regarded as unsigned int. In either case, it takes 4 bytes.

This size is determined by the compiler and cannot be changed. But you can be flexible.

If it is determined that one byte is enough, you can define the char type and then assign the required enum type.

For example:

enum {FALSE,TRUE };

There is no naming enumeration here, and then definition.

typedef char BOOL

In this way, this BOOL type occupies one byte, and both FALSE and TRUE enumeration values can be used at the same time.