---
title: "C++ 结构体字节占比分配"
author: "mylove2060"
date: "2011-09-14T20:15:14Z"
tags: []
categories: ["编程语言"]
slug: "c"
draft: false
lastmod: "2011-09-14T20:15:14Z"
id: 1172022
url: "https://cooker.iteye.com/blog/1172022"
---

```c++

struct Param
{
	unsigned long A : 8;
	unsigned long B : 24;

	Param()
	{
		memset(this, 0, sizeof(Param));
	}
};


Param param;
param.A = 0xffffffff;
param.B = 0xffffffff;

//A为0x000000ff
//B为0x00ffffff

```