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