Chinaunix首页 | 论坛 | 博客
  • 博客访问: 17623
  • 博文数量: 13
  • 博客积分: 310
  • 博客等级: 二等列兵
  • 技术积分: 140
  • 用 户 组: 普通用户
  • 注册时间: 2011-08-15 09:35
文章分类
文章存档

2011年(13)

我的朋友
最近访客

分类:

2011-08-19 15:44:33

  1. #include<iostream>
  2. using namespace std;paper cutting machine

  3. typedef void(__stdcall *callPrint)(int n); //声明callPrint类型的函数指针
  4. void __stdcall Print(int n) //回调函数
  5. {
  6.       for(int i = 0; i < n; i++)
  7.       {
  8.               cout <<"print " << i << endl;
  9.      }
  10. }

  11. void function(callPrint p, int n) //该函数调用回调函数,回调函数的指针为它的一个参数
  12. {
  13.       p(n);
  14. }

  15. int main()
  16. {
  17.      int n;
  18.      cin >> n;
  19.      callPrint p; //定义一个callPint函数指针
  20.      p = Print;            //将Print函数入口地址赋给p
  21.      function(p, n);        //fuction函数将调用Print函数
  22.      system("pause");
  23.      return 0;
阅读(561) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~