函数注册与回调实例
来源:互联网 发布:linux安装tomcat8 编辑:程序博客网 时间:2024/05/22 03:26
#include <iostream>
#include <map>
#include <string>
using namespace std;
int print(int a, int b)
{
cout << "Function of Print a: " << a << " b: " << b << endl;
return a+b;
}
int main()
{
string codeStr;
cout << "Input Code String: ";
cin >> codeStr;
typedef int (*function)(int, int);
map< string, function > mapProc;
mapProc[codeStr] = print;
string codeTest;
cout << "Input Test Code String: ";
cin >> codeTest;
map<string, function>iterator it = mapProc.find( codeTest );
if (it != mapProc.end())
{
int ret1 = ((*it).second)(1, 3);
cout << "Call Back Function ret1: " << ret1 << endl;
function fp = (*it).second;
int ret2 = fp(4, 7);
cout << "Call Back Function ret2: " << ret2 << endl;
}
else
{
cout << "CodeTest string not equal CodeStr....." << endl;
}
return 0;
}
- 函数注册与回调实例
- 函数的注册与回调【经验】
- 注册与回调
- 注册与回调
- 注册与回调
- 注册与回调
- 注册与回调
- 回调函数与注册函数
- js封装函数,让dom操作与函数分离 处理用户名注册实例
- C语言注册回调实例
- 【C++】注册与回调
- GLUT函数说明--注册回调
- ContentObserver回调与ContentProvider注册notifychange
- 指针函数回调实例
- 注册SMS接收回调函数实例
- prepend()与prependTo()函数实例
- 函数file_put_contents();详解与实例
- Android入门实例三 注册界面的设计与实现
- HDU1856:More is better(并查集)
- 图像卷积与滤波的一些知识点
- 记录一个breed服务器地址
- 洛谷 1449——后缀表达式(线性数据结构)
- 第二章 Spring MVC入门
- 函数注册与回调实例
- struts.xml配置问题
- tensorflow的安装教程(基于Ubuntu)
- 【jzoj4264】【tty妹子的函数】
- Linux网络预备知识
- hellow world
- mysql数据库服务提示This function has none of DETERMINISTIC的解决方法
- 第一章 Web MVC简介
- 基于Ceph快照的异地灾备设计