sizeof(enum)
来源:互联网 发布:财会软件 编辑:程序博客网 时间:2024/06/06 20:19
在看代码的时候遇到
typedef enum { RB_RED, RB_BLACK } RB_Color;template <class T> struct BinNode { T data; BinNode<T> *parent; BinNode<T> *lChild; BinNode<T> *rChild; int height; int npl; RB_Color color; }
发现不知道sizeof(RB_Color)
等于多少…..
枚举常量是另外一种类型的常量。枚举是一个常量整型值的列表。
枚举是为了能比#define
更加方便的定义常量,优势在于常量值可以自动生成。在没有显示的说明的情况下,enum类型中第一个枚举名的值为0,后面的值 = 前驱值 + 1。
由于RB_RED
为0,RB_BLACK
为1,这些常量都是可以用int的范围来表示的,所以sizeof(RB_Color) = sizeof(int)
。
typedef enum { SmNum = 0, BgNum = 0x8 0000 0000 } Num
其中BgNum
需要用long int
才能表示,所以sizeof
为 = 8(64位)
0 0
- sizeof(enum)
- sizeof vs. strlen enum
- struct、union、enum and sizeof
- sizeof(enum week)为什么是4?
- 《C关键字分析》之sizeof,enum、union和struct
- enum
- enum
- enum
- enum
- enum
- enum
- enum
- ENUM
- enum
- enum
- enum
- enum
- enum
- whose view is not in the window hierarchy
- 如何解决ajax跨域问题(转)
- hausdorff距离
- C语言之实际问题——指针赋值
- 地图map控件基本参数设置
- sizeof(enum)
- Hadoop序列化机制及实例
- 基于Android 4.4 开发的多窗口系统 开放源码
- Codeforces 467C George and Job(dp)
- ETL DataStage实现
- UIButton的基础语法
- EF大数据批量处理----BulkInsert
- 排序算法之(1)——冒泡排序
- [leetcode] 3Sum Closest