码迷,mamicode.com
首页 > 编程语言 > 详细

C++学习笔记:指向函数的指针

时间:2014-06-12 11:27:13      阅读:231      评论:0      收藏:0      [点我收藏+]

标签:style   class   blog   code   java   http   

bubuko.com,布布扣
 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 }
bubuko.com,布布扣

 


//第一个参数为指向函数的指针,返回类型为int,参数是int,int

bubuko.com,布布扣
 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 }
bubuko.com,布布扣

 

C++学习笔记:指向函数的指针,布布扣,bubuko.com

C++学习笔记:指向函数的指针

标签:style   class   blog   code   java   http   

原文地址:http://www.cnblogs.com/Androider123/p/3782401.html

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