且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

“类型为"void(exeCallback :: *)(int)"的值"不能将其分配给类型为"void(*)(int)"的实体,

更新时间:2022-11-30 11:35:43

该错误告诉您正在尝试将成员函数的指针分配给(非成员)函数的指针.有关差异的更多信息,请参见[here](错误告诉您正在尝试将成员函数的指针分配给(非成员)函数的指针.)看来您需要将 foo 声明为

The error is telling you that you are trying to assign a pointer to a member function to a pointer to a (non-member) function. See [here](The error is telling you that you are trying to assign a pointer to a member function to a pointer to a (non-member) function.) for more on the differences. It looks like you need to declare foo as

void (exeCallback::*foo)(int);

或者通过使用 std :: function 来使您的生活更轻松代码> (如果没有C ++ 11支持,则为 boost :: function ).

Or make your life easier by using std::function (or boost::function if you don't have C++11 support).