I always thought that in C++, as well as in C, enum
are just integers. But today I got this "invalid conversion from int
to E
":
enum E {
FIRST = 0b01,
SECOND = 0b10,
THIRD = FIRST | SECOND // this is fine
};
int main()
{
E first = FIRST;
E third = FIRST | SECOND; // this is NOT fine
return 0;
}