C++中的函数指针用法

代码:

 1 #include <iostream>
 2 #include <cstdio>
 3 typedef void (*FUN)();
 4 using namespace std;
 5 void k(){
 6     cout<<"k"<<endl;
 7 }
 8 int main(){
 9     FUN p = NULL;
10     p = k;
11     (*p)(); //运行程序
12 }
View Code

输出:

k

 

posted @ 2016-04-13 23:39  hu983  阅读(144)  评论(0编辑  收藏  举报