您可以在这里快速查找:


 
您的位置: 编程学习 > C++/VC > 200601
文章分类

Java技术
2005: 03 04 05 06 07 08
09 10 11 12
2006: 01 02

Asp.net
2005: 07 08 09 10 11 12
2006: 01 02

VB编程
2006: 02

Asp编程
2005: 11 12
2006: 01 02

C++/VC
2005: 10 11 12
2006: 01 02

Delphi
2005: 12
2006: 01 02

其它

 本文章适合所有读者

C++ 函数指针调用方式

zf0579

// 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;
}