标签:style class blog code java http
1 #include <stdio.h> 2 3 int sum(int a, int b) 4 { 5 return a+b; 6 } 7 8 int minus(int a, int b) 9 { 10 return a-b; 11 } 12 13 int x(int a, int b) 14 { 15 return a*b; 16 }
//第一个参数为指向函数的指针,返回类型为int,参数是int,int
1 void counting(int (*p)(int, int), int a, int b) 2 { 3 int result = p(a, b); 4 printf("result = %d\n", result); 5 } 6 7 int main() 8 { 9 //指向函数的指针 10 counting(sum, 1, 2);//counting(minus, 1, 2); counting(x, 1, 2); 11 return 0; 12 }
C++学习笔记:指向函数的指针,布布扣,bubuko.com
标签:style class blog code java http
原文地址:http://www.cnblogs.com/Androider123/p/3782401.html