0
enum Color
 {
   GREY = 4294967294,
   RED 
 }

RED is assigned the largest value a 4 byte unsigned int can hold. When I use sizeof to know the size of my enum Color (sizeof (Color)), it prints 4. If I assign -1 to RED, the sizeof prints 8. Does that mean an enum is by default unsigned?

  • I want to know the default state of an enum. Is it signed or unsigned. It's not a duplicate in my view. –  Jul 31 '15 at 06:52
  • 1
    I don't know what you mean by *default state*. The highest voted answer in the linked dupe states quite unambiguously what the behavior is. When you assign `-1` to `RED`, the only signed type that can hold both the enumerator values you've specified is a `long long`. – Praetorian Jul 31 '15 at 07:04

0 Answers0