This question already has an answer here:
- Are C++ enums signed or unsigned? 8 answers
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?
Aucun commentaire:
Enregistrer un commentaire