struct 中的变量声明语句中的冒号运算符

可能重复:
‘unsigned temp:3’是什么意思

struct sample{ int x :2; char y :4; }; 

冒号操作符在上面的代码中做了什么?

它用于指定位字段。 字段的大小以位给出。 布局是特定于编译器的。