码迷,mamicode.com
首页 > 其他好文 > 详细

函数指针

时间:2017-09-20 20:10:17      阅读:142      评论:0      收藏:0      [点我收藏+]

标签:out   函数   color   handle   ati   用法   pre   type   style   

 

函数指针的定义一般类似为:int (* func)();
而指针函数定义一般为:int *func(); //代表返回值是一个整型指针

还有一种类似于函数指针的定义法为:typedef int (* func)(void);
这个和函数指针的区别在于,这个是定于一种类型,而函数指针是定义一个变量。这种类型为一个,指向返回值为整型的指针,

用法如下:

typedef void  (* FUNC)();
static void handleMovieTimout()
{
    ...
}
void main()
{
    static FUNC mFunc = NULL;//让mFunc为一个函数指针
    mFunc=handleMovieTimout;//因为mFunc为void类型的函数指针,所以指向了handleMovieTimout的地址
    mFunc();//这样就相当于调用了handleMovieTimout函数
}

 

函数指针

标签:out   函数   color   handle   ati   用法   pre   type   style   

原文地址:http://www.cnblogs.com/lijimmy/p/7563366.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!