现在的位置: 首页 > 综合 > 正文

class, struct, union

2014年02月26日 ⁄ 综合 ⁄ 共 258字 ⁄ 字号 评论关闭
class my
{
public:
	struct
	{
		unsigned _a: 4;
		unsigned _b: 4;
		unsigned _c: 4;
		unsigned _d: 4;
	};

	struct // 没有必要
	{
		int _e;
		int _f;
	};

	int _g;
	union
	{
		int _fa;
		int _fb;
	};
};

int _tmain(int argc, char* argv[])
{
	my tb;
	tb._fa = 1;
	tb._a = 2;
	tb._e = 3;
	cout << tb._fb<< endl;
	cout << tb._a << endl;
	cout << tb._e << endl;
	return 0;
}

抱歉!评论已关闭.