测试代码显示如下:
#include<iostream>
using namespace std;
typedef int(LogCallbackFunc)(int *log);
int setLogFuncCallback(int param, LogCallbackFunc cbFunc)
{
int temp = param + 10;
int * strLog = new int(temp);
cbFunc(strLog);
int c = *strLog;
cout << "c= " << c << end;
return 0;
}
int realLogCallback1(int *strLog)
{
int b;
b = *strLog;
return 0;
}
int realLogCallback2(int *strLog)
{
int b = 20;
*strLog = b;
return 0;
}
int main()
{
setLogFuncCallback(5, realLogCallback1);
cout << "********************" << endl;
setLogFuncCallback(5, realLogCallback2);
return 0;
}