天天看點

創新工場筆試題

typedef union{
	long i;
	int a[5];

	double b;
}U;
typedef struct {
	
	int a1;
	U a;
	
	double b1;
}M;
cout<<sizeof(M);
           

結果為40;

結構體内的對齊應該是以double類型大小8對齊的

是以記憶體配置設定是:

int a1;//8位元組

U a;//24位元組

double b1;//8位元組

繼續閱讀