OC typedef(起别名)
// #define Integer int
// 给基本数据类型起别名
void test() {
typedef int Integer; typedef Integer MyInteger; typedef unsigned int UInteger; int a = ; Integer b = ; UInteger c = ; MyInteger d = ;
} // 给指针类型起别名
void test1() {
char *s = "itcast"; typedef char * String; String s1 = "itcast";
} void test2() {
// struct MyPoint {
// float x;
// float y;
// };
// struct MyPoint p = {10, 10}; typedef struct {
float x;
float y;
} Point; Point p = {, };
} void test3() {
typedef struct {
float x;
float y;
} Point; typedef Point * PP; // typedef struct Point {
// float x;
// float y;
// } * PP; Point point = {10.0f, 20.0f}; PP pp = &point; printf("x=%f, y=%f\n", pp->x, pp->y);
} void test4() {
typedef enum {
spring,
summer,
autumn,
winter
} Season; Season s = spring;
} int sum(int a, int b) {
int c = a + b;
printf("%d+%d=%d\n", a, b, c);
return c;
} // 给指向函数的指针定义一个别名SumPoint
void test5() {
typedef int (*SumPoint)(int, int); SumPoint p = sum; (*p)(, );
} void test6() {
typedef char * String1;
#define String2 char * String1 s1,s2;
// String1 s1;
// String1 s2; String2 s3,s4;
// char *s3, s4;
// char *s3;
// char s4;
} int main(int argc, const char * argv[])
{ int a, b; // int a;
// int b; return ;
}
OC typedef(起别名)的更多相关文章
- dart中的typedef <函数别名>
typedef定义如下: typedef 给某一种特定的函数类型起了一个名字,可以认为是一个类型的别名.或者这样理解: 自己定义了一种数据类型,不过这种数据类型是函数类型,按照这种类型实例化后的对象, ...
- Item 9: 比起typedef更偏爱别名声明(alias declaration)
本文翻译自modern effective C++,由于水平有限,故无法保证翻译完全正确,欢迎指出错误.谢谢! 博客已经迁移到这里啦 我确信我们都同意使用STL容器是一个好主意,并且我希望在Item ...
- C语言结构体及typedef关键字定义结构体别名和函数指针的应用
结构体(struct)的初始化 struct autonlist { char *symbol; struct nlist nl[2]; struct autonlist *left, *right; ...
- 用typedef自定义类型语法你真的会吗
关于typedef 我们学习typedef的时候,他的定义语法是:typedef+类型+别名,但是按照上面的格式,自定义数组怎么定义呢,是这样tepedef int a[10] 别名?还是这样tep ...
- typedef和#define
typedef:在计算机编程语言中用来为复杂的声明定义简单的别名(给类型起别名,整体类型替换),它本身是一种存储类的关键字,与auto.extern.mutable.static.register等关 ...
- OC 和 swift 小结
1 什么是 OC 语言? OC 语言即面向对象语言,它扩展了 ANSI C 语言,将 SmallTalk 式的消息传递机制加入到 ANSI C 中.它是苹果 OS 和 iOS 以及相关的 API,Co ...
- C 中typedef 函数指针的使用
类型定义的语法可以归结为一句话:只要在变量定义前面加上typedef,就成了类型定义.这儿的原本应该是变量的东西,就成为了类型. int integer; //整型变量int *pointer ...
- typedef使用
1.利用typedef定义函数指针 代码简化,促进跨平台开发 typedef行为有点类似#define 宏,用其实际类型替代同义字. 不同点:typedef 在编译时被解释,因此让编译器来 应付超 ...
- C++------------typedef 函数指针类型定义
摘要bycrazyhacking: typedef 是定义了一种"函数指针"类型,可以再声明很多变量.函数指针的定义是定义了一个变量. int max(int x,i ...
随机推荐
- 【温故知新】c#抽象类abstract与接口interface
1.什么是抽象类 先来看MSDN对抽象类描述: 抽象类是一些留有部分或全部成员未实现的类,以便可以由派生类来提供实现. 在面向对象的编程中,抽象类用作层次结构的基类,并表示不同对象类型组的通用功能. ...
- TOJ 4002 Palindrome Generator
描述 A palindrome is a number that reads the same whether you read it from left to right or from right ...
- unity摄像机移动滑动
之前写了一个pc版本的 // 当按住鼠标左键的时候 //if (Input.GetMouseButton(0)) //{ // // 获取鼠标的x和y的值,乘以速度和Time.deltaTime是因为 ...
- [Activator- HelloAkka] Define our Messages
An Actor does not have a public API in terms of methods that you can invoke. Instead its public API ...
- nyoj 1192——Salvation——————【搜索】
Salvation 时间限制:1000 ms | 内存限制:65535 KB 难度:3 描述 神秘瀑布镇是一个神秘的地方,那里有吸血鬼,狼人,巫师,二重身. Klaus(吸血鬼祖先) 为了利用 ...
- 删除.browserslistrc文件就好了
$ npm run dev > bootstrap-vue@1.0.0 dev E:\aawork\1work\2019.2\bootstrap-vue> webpack-dev-serv ...
- 1个示例 学会 mvc 常用标签
HtmlHelper用法大全3:Html.LabelFor.Html.EditorFor.Html.RadioButtonFor.Html.CheckBoxFor @Html.***For:为由指定 ...
- VS 正则表达式替换内容
很少使用VS的正则替换功能,最近因为需要添加大量的默认值,但是又不想重新类,就想到了这个. 1.替换带有///描述的属性 查找的正则表达式: /// <summary>((.)*((.|\ ...
- SpringSecurity 3.2入门(7)自定义权限控制介绍
总结Spring Security的使用方法有如下几种: 一种是全部利用配置文件,将用户.权限.资源(url)硬编码在xml文件中. 二种是用户和权限用数据库存储,而资源(url)和权限的对应关系硬编 ...
- 关于EF执行返回表的存储过程
1.关于EF执行返回表的存储过程 不知道为什么EF生成的存储过程方法会报错,以下方法可以使用,call是MySQL执行存储过程的命令 [HttpGet] public HttpResponseMess ...