【发布时间】:2013-02-10 09:39:02
【问题描述】:
我想通过具有未知参数的函数指针调用函数。存储输入参数和函数并稍后运行。 php中的call_user_func_array之类的东西
例如:
// example function definition
void foo(int arg1, const char *arg2,const char *arg3){
//some other code
}
void bar(int arg1, int arg2){
//some other code
}
// function definition
void store_function_call(int param,void *function,... args){
// store param , function, and other arguments
// in php save to global variable for use later
}
void call_later(){
// execute stored param, function, arguments
// in PHP use call_user_func_array
}
// use:
int main(){
store_function_call(10,bar,4,5);
// store_function_call(5,foo,5,"yyy","sss");
call_later();
}
【问题讨论】:
-
你可能想使用 Boost::bind。
标签: c++ function-pointers invoke