我遇到了一种我以前从未见过的语法。
typedef struct SomeStruct
{
unsigned char ip_version :4;
unsigned char ip_tos;
unsigned char ip_frag_offset :5;
unsigned char ip_more_fragment :1;
unsigned char ip_dont_fragment :1;
unsigned char ip_reserved_zero :1;
unsigned char ip_frag_offset1;
unsigned char ip_ttl;
} SomeHeader;
是colon #;
为了什么?这和使用赋值运算符一样吗?为什么使用冒号,是否有优点或允许这样做的原因?