正在阅读:C++基础:函数指针调用方式C++基础:函数指针调用方式

2004-03-16 15:14 出处:CSDN 作者:zf0579 责任编辑:linjixiong
  // test12.cpp : Defines the entry point for the console application.
  //

  #include "stdafx.h"

  void func(int i)
  {
  printf("This is for test %i\r\n", i);
  }

  typedef void (*PFUNC)(int);

   struct FUNC
  {
  PFUNC pfunc;
  };
 
  void callfunc(void pfunc(int), int i)
  {
  pfunc(i);
  }

  int main(int argc, char* argv[])
  {
  void (*pfunc)(int);
  pfunc = &func;
  pfunc(1);

  callfunc(pfunc, 2);

  FUNC sfunc;
  sfunc.pfunc = &func;
  sfunc.pfunc(3);

  return 0;
  }
 




察看评论详细内容 我要发表评论
作者笔名简短内容 发表时间
:

相关文章

关注我们

最新资讯离线随时看 聊天吐槽赢奖品