相关疑难解决方法(0)

C++中的回调函数

在C++中,何时以及如何使用回调函数?

编辑:
我想看一个简单的例子来编写回调函数.

c++ function-pointers callback

281
推荐指数
8
解决办法
38万
查看次数

通用回调

扩展

有关

所以,我正在尝试更好地学习模板元编程,我认为这是一个很好的练习.

我正在尝试编写可以使用我传递给它的任意数量的参数回调函数的代码.

// First function to call
int add( int x, int y ) ;

// Second function to call
double square( double x ) ;

// Third func to call
void go() ;

回调创建代码应如下所示:

// Write a callback object that
// will be executed after 42ms for "add"
Callback<int, int, int> c1 ;
c1.func = add ;
c1.args.push_back( 2 );  // these are the 2 args
c1.args.push_back( 5 );  // to pass to the "add" function
                         // …

c++ templates metaprogramming

5
推荐指数
1
解决办法
1027
查看次数