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

Dr *_*Deo 1 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************************   
};
Run Code Online (Sandbox Code Playgroud)

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

bool DCFrameListener::keyPressed(const OIS::KeyEvent kEvt)
{
    return true;
}
Run Code Online (Sandbox Code Playgroud)

编译器拒绝此错误

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

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

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

GMa*_*ckG 12

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

bool keyPressed(const OIS::KeyEvent & kEvt);
                                    ^!
bool DCFrameListener::keyPressed(const OIS::KeyEvent kEvt)
                                                    ^?
Run Code Online (Sandbox Code Playgroud)

  • 有趣的是,眼睛可以掩盖这样的事情. (4认同)