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

函数指针

时间:2014-09-09 15:32:38      阅读:175      评论:0      收藏:0      [点我收藏+]

标签:style   blog   color   使用   div   sp   log   c   amp   

int    f(int);     //函数声明
int    (*pf) = &f;    /*函数指针初始化 其中&符号时可选的,因为函数名被使用时总是由编译器转换为函数指针*/

//函数指针声明并初始化后, 可以用3中方法调用

int    ans;
ans = f(3);
ans = pf(3);
ans = (*pf)(3);

//同样, 函数指针中的*符号是可选的, 因为即使使用了, *pf最终也会被编译器转换为 指针pf。编译器最终需要的是一个指针。

 

函数指针

标签:style   blog   color   使用   div   sp   log   c   amp   

原文地址:http://www.cnblogs.com/shaughn/p/3962457.html

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