EventReceiver in the header file...

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
Pythy Python
Posts: 30
Joined: Sun Mar 29, 2015 1:31 am

EventReceiver in the header file...

Post by Pythy Python »

Because I don't like all of my codes in my main.cpp, I decided to move EventReceiver code to receiver.h and receiver.cpp


main.cpp

Code: Select all

 
int main(){
    EventReceiver receiver;
 

receiver.h

Code: Select all

 
#ifndef RECEIVER_H
#define RECEIVER_H
 
 
#include "include/irrlicht.h"
 
using namespace irr;
 
 
class EventReceiver: public IEventReceiver{
    public:
        virtual bool onEvent(const SEvent& event);
 
        virtual bool keyCheck(EKEY_CODE keyCode) const;
 
        EventReceiver();
 
    private:
        bool keyIsDown[KEY_KEY_CODES_COUNT];
};
 
 
#endif
 
receiver.cpp

Code: Select all

 
#include "receiver.h"
 
 
bool EventReceiver::onEvent(const SEvent& event){
    if(event.EventType == irr::EET_KEY_INPUT_EVENT){
        keyIsDown[event.KeyInput.Key] = event.KeyInput.PressedDown;
    }
 
    return false;
}
 
bool EventReceiver::keyCheck(EKEY_CODE keyCode) const{
    return keyIsDown[keyCode];
}
 
EventReceiver::EventReceiver(){
    for(u32 i = 0; i < KEY_KEY_CODES_COUNT; ++i){
        keyIsDown[i] = false;
    }
}
 


I'm getting an error...

Code: Select all

 
main.cpp: In function 'int main()':
main.cpp:9:16: error: cannot declare variable 'receiver' to be of abstract type
'EventReceiver'
  EventReceiver receiver;
                ^
In file included from main.cpp:3:0:
receiver.h:10:7: note:   because the following virtual functions are pure within
 'EventReceiver':
 class EventReceiver: public IEventReceiver{
       ^
In file included from include/ISceneNodeAnimator.h:12:0,
                 from include/ISceneNode.h:12,
                 from include/IAnimatedMeshSceneNode.h:8,
                 from include/irrlicht.h:59,
                 from main.cpp:2:
include/IEventReceiver.h:446:15: note:  virtual bool irr::IEventReceiver::OnEven
t(const irr::SEvent&)
  virtual bool OnEvent(const SEvent& event) = 0;
 

What's my problem?
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: EventReceiver in the header file...

Post by CuteAlien »

It's OnEvent with upper-case O. C++ is case sensitive.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Post Reply