提问人:Ivo Ribeiro 提问时间:5/16/2023 更新时间:5/16/2023 访问量:28
回调参数假定类表示法
Callback Argument assuming class notation
问:
我在 API 上定义了一个提取方法,该方法需要 ID 和回调功能。
extractAsync(const std::string &name, void (*callback)(int)
但是我在类中定义回调函数,因为我需要访问其中的其他内容。
class CommandBuilder { public: //... void onExtractionChanged(int result); }
我的问题是,因为它在类内部,当我作为参数传递时,它说无效的参数类型。
argument of type "void (CommandBuilder::*)(int result)" is incompatible with parameter of type "void (*)(int)"
(为了解释问题,我简化了一些代码,如果你还有其他疑问请问)
我试过什么:
- Lambda 函数;
- 从类中删除(无法访问我需要的其他内容,也无法将它们作为参数传递)
- 添加到类中(给出这个奇怪的错误,因为它不是'void()(int)',而是'void (CommandBuilder::)(int result)')
答: 暂无答案
评论
extractAsync
static
this
void*