c++ struct, union,enum,typedef
来源:互联网 发布:手机淘宝 尺码助手 编辑:程序博客网 时间:2024/05/16 11:24
struct结构体,声明时可以
struct CoordSlice{int a;int b;};
CoordSlice cs = { 1, 2};
union 共用体,一种没多大作用的结构。主要目的是为了节约内存。
定义,声明类似struct,union的大小为其中最大成员变量的大小,定义时,其中可以放置多个变量,但是,保存在内存中的只有最近一次赋值的变量。其中的变量不是完整的进行保存,只是放一会就扔了。
union un{int a;float b;double c;long long d;};
enum 枚举
enum aa{a12,G22,D414,afsfa,awgag,fa};
枚举中的是枚举常量,其值为序号,为整数,其实这就是在声明几个整数型常量而已,用一个枚举将这些名称与值对应,提供代码可读性。对于使用时,可以
int l = a12;
int k = aa(0);这两个效果是相同的,都是赋值 0。
typedef 用于声明类型,为类型起一个别名,也是为了提高代码可读性。
typedef int* int_p;typedef aa bb;
0 0
- C语言入门-struct&union&enum&typedef
- C语言中的struct、union、enum、Typedef
- C语言中的struct、union、enum、Typedef
- c++ struct, union,enum,typedef
- C语言中-const,volatile-struct,union-enum,typedef,define
- 自定义数据类型(typedef,enum,struct,union)
- C的struct, union, enum
- c中枚举类型enum, struct, union
- c++——union、struct、enum
- C语言深度解剖——读书笔记-3、关键字(const、 volatile、extern、struct、union、enum、typedef)
- enum union #define typedef
- union、enum、typedef
- struct union enum
- enum struct union
- struct/enum/union用法
- <struct、union、enum>差异
- struct union enum
- C语言难点专题——enum, struct 和 Union
- poj 1584 A Round Peg in a Ground Hole
- 区间
- javascript父、子页面交互小结
- PHP中获取当前页面的完整URL
- 传话游戏
- c++ struct, union,enum,typedef
- 第六周作业1——利用哈夫曼编码英文字母表
- 语言模型n-gram
- utf8截取无乱码
- PHP数组排序
- http的安全方法和幂等性
- Android 四大组件生命周期:ContentProvider
- 关于分词sphinx和cookindex的简单记录
- struts2第一个应用