回调函数另解
来源:互联网 发布:if函数c语言 编辑:程序博客网 时间:2024/06/16 06:41
#include <iostream>
#include <string>
using namespace std;
typedef void(*pcb1)(char *);
typedef void(*pcb2)(long value);
typedef void(*pcb3)(string str);
struct Funtion
{
pcb1 f1;
pcb2 f2;
pcb3 f3;
}myFun;
void GetCallBack(Funtion fun)//(pcb1 callback)
{
/*do something*/
char buffer[] = "hello world!";
//callback(buffer);
fun.f1(buffer);
}
void CallbackFun1(char *s)
{
/* do something */
cout<<s<<endl;
cout<<"call CallbackFun1!"<<endl;
}
void CallbackFun2(char *s)
{
/* do something */
cout<<s<<endl;
cout<<"call CallbackFun2!"<<endl;
}
void CallbackFun3(char *s)
{
/* do something */
cout<<s<<endl;
cout<<"call CallbackFun3!"<<endl;
}
pcb1 funArray[3] = {CallbackFun1,CallbackFun2,CallbackFun3};
int _tmain(int argc, _TCHAR* argv[])
{
Funtion myFuntion;
for(int i=0;i<3;i++)
{
myFuntion.f1 = funArray[i];
GetCallBack(myFuntion);
}
return 0;
}
- 回调函数另解
- .NET 回调函数
- 回调函数
- 回调函数
- 回调函数概念
- 回调函数
- 回调函数
- 回调函数
- 回调函数 相关
- delphi 回调函数
- 回调函数
- 回调函数
- 回调函数学习
- 回调函数
- 关于回调函数
- 透析回调函数
- 回调函数
- 回调函数小例
- 2012计划_工作准备篇
- 程序员编写ASP.NET应用程序的十大技巧
- Struts2 JFreeChart 实例整合
- struts2和json交互
- js时间日期控件
- 回调函数另解
- oracle日期函数
- ubuntu 64 server 环境安装php5.3.10+mysql5.5.20+apache2.2.22
- jQuery Ajax 实例 全解析
- JQury Ajax
- http://www.iteye.com/job/topic/1119480?page=4http://www.iteye.com/job/topic/1119480?page=4
- 【Android】代码开启/关闭GPS .
- scanf与printf转换说明符区别
- 【已解决】我遇到的 bad flag(parameter or structure field)(Unrecognized or unsupported array type)