2011年3月27日
摘要: 转自:http://blogold.chinaunix.net/u2/84450/showart_1829958.html 在C/C++程序的编写中,当多个基本数据类型或复合数据结构要占用同一片内存时,我们要使用联合体;当多种类型,多个对象,多个事物只取其一时(我们姑且通俗地称其为“n 选1”),我们也可以使用联合体来发挥其长处。首先看一段代码:union myun{ struct { int x; int y; int z; }u; int k;}a;int main(){ a.u.x =4; a.u.y =5; a.u.z =6; a.k = 0; printf("%d %d % 阅读全文
posted @ 2011-03-27 16:39 c++_thinker 阅读(678) 评论(0) 推荐(0)