枚举和结构体
2017-02-24 16:23
197 查看
1.枚举类型
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
2.结构体
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
//推荐的定义枚举类型的方式 typedef NS_ENUM(NSInteger, RWTLeftMenuTopItemType) { RWTLeftMenuTopItemMain, RWTLeftMenuTopItemShows, RWTLeftMenuTopItemSchedule }; typedef NS_ENUM(NSInteger, RWTGlobalConstants) { RWTPinSizeMin = 1, RWTPinSizeMax = 5, RWTPinCountMin = 100, RWTPinCountMax = 500, }; //不推荐的方式 enum GlobalConstants { kMaxPinSize = 5, kMaxPinCount = 500, };1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
2.结构体
//1.定义一个Sample结构体 struct Sample { int a; int b; int c; }; //初始化的时候,可以这样赋值 struct Sample sampleStruct = {1, 2, 1}; NSLog(@"sampleStruct中的值%d",sampleStruct.a ); //2 .定义一个Sample结构体 struct Sample{ int a; int b; int c; }sampleStruct; typedef struct Sample MySampleStruct; //以后用这个结构体,就可以直接用MySampleStruct去定义了 MySampleStruct samDefineStructVarible = {1,2,1}; samDefineStructVarible.a = 1; samDefineStructVarible.b =2; samDefineStructVarible.c = 3;1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
相关文章推荐
- Swift-枚举、结构体、协议
- Swift语言学习4--枚举和结构体
- C++ 共用体 枚举 结构体 介绍
- 嵌入式开发第9天(结构体,枚举,共同体,typedef)
- 结构体 共同体 枚举
- 结构体 枚举 typedef
- 黑马程序员——C语言之构造类型(结构体、枚举)
- (第一天)object-c枚举和结构体
- C语言第七节-结构体-枚举-typedef
- c语言学习笔记之结构体,枚举
- 浅谈swift中的那些结构体和枚举
- STM32 枚举类型和结构体的使用
- 数据类型(基本内置类型)——枚举(枚举类型)、结构体(构造类型)、联合体(构造类型)
- 枚举、结构体、联合体的简单应用程序-C语言
- 结构体与枚举的区别
- 结构体-位段-联合体-枚举
- 项目5点结构体与枚举
- 枚举,结构体、、、
- C语言03_构造类型 数组, 结构体, 共用体, 枚举类型介绍
- 黑马程序员_C语言学习笔记之结构体和枚举