Is there a difference between 0 and 0x0000 in the start value of an enum?

c++, enums

Solution

No difference, it's just a readability thing. For instance, it indicates that the enumeration values are used in some sort of binary context, such as bitflags.

enum Flags {
    FLAG_NONE   = 0x0000,
    FLAG_READ   = 0x0001,
    FLAG_WRITE  = 0x0002,
    FLAG_APPEND = 0x0004,
    FLAG_TEXT   = 0x0008,
    FLAG_MEMMAP = 0x0010
};

Problem

Does this change the way the values are stored or incremented at all within the enum? If they are the same, why do people define it as 0x000?

Original source

Related problems