Reputation: 507
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?
Upvotes: 3
Views: 12129
Reputation: 96251
There is no difference for those specific values, they're exactly the same.
But for other values, remember that prepending 0
makes it an octal constant. This means you want to avoid using values like 000
, 001
, 002
, 010
, 044
, etc (in an attempt to keep the length of the constants equal).
Upvotes: 0
Reputation: 14792
No.
0x0000 (append as many 0's as you want) is just 0 in hexadecimal.
Sometimes all your numbers in the enum are hexadecimal. Since there are all hexadecimal your just define the first one in hexadecimal too, because it looks cleaner.
Upvotes: 3
Reputation: 361645
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
};
Upvotes: 9