首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

typedef跟指针结合

2012-10-06 
typedef和指针结合1.?typedef (int *) pInt2.typedef pInt (int *)对于pInt a,b第一种:int *aint *b

typedef和指针结合
1.?typedef (int *) pInt;
2.typedef pInt (int *);

对于pInt a,b;
第一种:int *a;int *b;
第二种: int*a,b; //b为int 型。


声明函数指针类型:
typedef int (*PF) (const char*,const char*);
语法:
1。typedef<返回类型>(*<函数类型名>)(参数表)
2.。typedef<返回类型>(<类名>::*<函数类型名>)(参数表)

调用:
PF(str1,str2);
(*PF)(str1,str2);
两者等效;(*PF)返回的是函数名。
PF是指针。


例子:
有一段程序存储在起始地址为0的一段内存上,如果我们想要调用这段程序,请问该如何去做?
答案:(*(void(*)())0)()

注意点:类型的转换,类型一定要加括号

热点排行