C union and bitfields

bit-fields, c++, unions

Can bitfields be used in union?

Best Solution

Yes, they can be. Why not? Bit-fields in unions behave in the same way they behave anywhere else. There's nothing special about bit-fields in unions (or unions with bit-fields).