重载函数成员C ++的问题

时间:2010-03-27 03:56:23

标签: c++ visual-c++

我已将类声明为

class DCFrameListener : public FrameListener, public OIS::MouseListener, public OIS::KeyListener  
{
    bool keyPressed(const OIS::KeyEvent & kEvt);
    bool keyReleased(const OIS::KeyEvent &kEvt);

//*******some code missing************************   
};

但是,如果我尝试定义这样的成员

bool DCFrameListener::keyPressed(const OIS::KeyEvent kEvt)
{
    return true;
}

编译器拒绝此错误

error C2511: 'bool DCFrameListener::keyPressed(const OIS::KeyEvent)' : overloaded member function not found in 'DCFrameListener'  
see declaration of 'DCFrameListener'

为什么会发生这种情况,但我在我的函数声明中声明了成员 keyPressed(const OIS :: KeyEvent)

任何帮助将不胜感激。感谢

1 个答案:

答案 0 :(得分:12)

声明中的那个有一个参考:

bool keyPressed(const OIS::KeyEvent & kEvt);
                                    ^!
bool DCFrameListener::keyPressed(const OIS::KeyEvent kEvt)
                                                    ^?
相关问题