我正在尝试重载 == 运算符以在两个对象之间进行比较。由于某种原因,重载的处理程序永远不会被调用。
class gxCallback
{
public:
virtual bool operator==(const gxCallback &aOther) const
{
// This is never called
return true;
}
};
typedef std::vector < gxCallback* > CallbackList;
void gxObservable::Fire( gxCallback *aCallback )
{
CallbackList::iterator iCallback;
for ( iCallback = mCallbacks.begin(); iCallback != mCallbacks.end(); ++iCallback )
{
if ( aCallback == *iCallback ) // The comparison is never made via the overloaded ==
{
// Do something
}
}
}