我正在尝试使用第三方 SDK(Crystal Space)并且遇到了一些问题。
代码(不是我的)如下所示:
#define CS_EVENTHANDLER_PHASE_LOGIC(x)
CS_EVENTHANDLER_NAMES(x)
CS_EVENTHANDLER_DEFAULT_INSTANCE_CONSTRAINTS
virtual const csHandlerID * GenericPrec
(csRef<iEventHandlerRegistry> &, csRef<iEventNameRegistry> &,
csEventID) const {
return 0;
}
virtual const csHandlerID * GenericSucc
(csRef<iEventHandlerRegistry> &r1, csRef<iEventNameRegistry> &r2,
csEventID event) const {
static csHandlerID succConstraint[6];
if (event != csevFrame(r2))
return 0;
succConstraint[0] = FrameSignpost_Logic3D::StaticID(r1);
succConstraint[1] = FrameSignpost_3D2D::StaticID(r1);
succConstraint[2] = FrameSignpost_2DConsole::StaticID(r1);
succConstraint[3] = FrameSignpost_ConsoleDebug::StaticID(r1);
succConstraint[4] = FrameSignpost_DebugFrame::StaticID(r1);
succConstraint[5] = CS_HANDLERLIST_END;
return succConstraint;
}
#define CS_EVENTHANDLER_PHASE_3D(x)
CS_EVENTHANDLER_NAMES(x)
CS_EVENTHANDLER_DEFAULT_INSTANCE_CONSTRAINTS
virtual const csHandlerID * GenericPrec
(csRef<iEventHandlerRegistry> &r1, csRef<iEventNameRegistry> &r2,
csEventID event) const {
static csHandlerID precConstraint[2];
if (event != csevFrame(r2))
return 0;
precConstraint[0] = FrameSignpost_Logic3D::StaticID(r1);
precConstraint[1] = CS_HANDLERLIST_END;
return precConstraint;
}
virtual const csHandlerID * GenericSucc
(csRef<iEventHandlerRegistry> &r1, csRef<iEventNameRegistry> &r2,
csEventID event) const {
static csHandlerID succConstraint[5];
if (event != csevFrame(r2))
return 0;
succConstraint[0] = FrameSignpost_3D2D::StaticID(r1);
succConstraint[1] = FrameSignpost_2DConsole::StaticID(r1);
succConstraint[2] = FrameSignpost_ConsoleDebug::StaticID(r1);
succConstraint[3] = FrameSignpost_DebugFrame::StaticID(r1);
succConstraint[4] = CS_HANDLERLIST_END;
return succConstraint;
}
(还有几个类似的块具有相同的函数名称)
如您所见,它们正在重载虚拟成本函数。
当我有代码时
CS_EVENTHANDLER_PHASE_LOGIC("application.cstest")
在我的头文件中,我收到此错误:
error: 'virtual const csEventHandlerID* CSTest::GenericSucc(...) const cannot be overloaded'
这对 GenericPrec、InstaceSucc 和 InstancePrec 重复。
我无法在 Google 上找到有关此错误的任何信息。似乎没有任何迹象表明虚拟常量不能被重载(开发人员似乎也是这么认为的)那么编译器的问题是什么?
tl;博士:
为什么我不能重载虚拟 const 函数?