一些代码
typedef void (*EventHandler) (EventObject* sender, EventArgs* args, void* closure);
class Control
{
void AddHandler(int eventId, EventHandler handler, void* data)
}
class SubControl
{
static void mousemove_cb(EventObject* sender, MouseEventArgs* calldata, void* closure);
}
错误
error C2664: 'Control::AddHandler' : cannot convert parameter 2 from 'void (__cdecl *)(EventObject *,MouseEventArgs *,void *)' to 'EventHandler'
这是产生错误的行:
control.AddHandler(MouseMoveEvent, mousemove_cb, 0);
描述
问题是 MouseEventArgs 是 EventArgs 的子类!那么,有没有办法进行自动转换并使用精确的“事件参数”注册我的方法?