0
你好我是一個學生在一個程序上工作我有一個使用成員函數的回調。我遇到了使用綁定,這正是我需要的。我只是很難得到它的工作。boost :: bind成員函數的回調幫助
下面是相關代碼和編譯錯誤
// this is the API function to register callback
void register_callback_datapoint(void(*)(datapoint_t *datapoint) cb_datapoint)
// this function is my callback
void datapoint_update(datapoint_t* datapoint);
// this code is called in the aggregateThread class
boost::function<void(datapoint_t*)> f;
f = bind(&aggregateThread::datapoint_update, this, std::tr1::placeholders::_1);
register_callback_datapoint(f);
// here is the compile error
cannot convert ‘boost::function<void(datapoint_opaque_t*)>’ to ‘void (*)(datapoint_t*)
{aka void (*)(datapoint_opaque_t*)}’ for argument ‘1’ to ‘void
register_callback_datapoint(void (*)(datapoint_t*))’
有人可以幫助我嗎?謝謝