I want to make an enum in such a way that I can & parameters after |ing them in.
Can I simply do:
enum Things
{
Something,
SomethingElse
};
Or must I be careful to give them specific numbers for this to work?
Also if a value, like say, 3, has already been |=’d in, would |= it in again cause this to malfunction (as in, if(attributes & 3) would no longer work)
Thanks
Then define your enum as:
The idea is, only one bit in the binary representation should be
1, others should be0, as shown in the comments above. Also, I used 8 bits only in the comment, that doesn’t mean that the enum values are one byte size. I only used them for convenience. Enum values can be very large, can hold evenlong.