2010-06-04 89 views
0

可能重複:
What does ‘unsigned temp:3’ meansC++結構定義

我剛剛發現在一本書這個代碼(在一個示例中使用)

typedef struct { 
unsigned int A:1; 
unsigned int B:1; 
unsigned int C:1; 
} Stage; 

是什麼這個結構定義的含義是什麼? (A:1;

+1

['unsigned temp:3'是什麼意思]的完全重複(http://stackoverflow.com/questions/2950029/what-does-unsigned-temp3-means)。 – 2010-06-04 21:40:33

回答

3

這些是C bitfields。在兼容的編譯器中,A B和C的組合不會佔用多於一個的int。 A,B和C在整數中佔據一位。