IEventReceiver interface

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
stryker1
Posts: 5
Joined: Mon May 01, 2006 1:16 am

IEventReceiver interface

Post by stryker1 »

I'm trying to move the MyEventReceiver class from one of the irrlicht examples to a seperate .cpp and .h file (clean up the code), but when I then try to make an instance of it, and feed it to createDevice it gives me this:

error C2259: 'MyEventReceiver' : cannot instantiate abstract class

here's my code

MyEventReceiver.h:
and
in my Game class:

Code: Select all

class MyEventReceiver : public IEventReceiver
{
public:
	virtual bool MyEventReceiver::OnEvent(SEvent event,IrrlichtDevice* device)
	{ 
		if (event.EventType == irr::EET_KEY_INPUT_EVENT)
		{
			switch(event.KeyInput.Key)
			{
			case irr::KEY_ESCAPE:
				{
					device->closeDevice();
				}
				return true;
			}
		}
		return false;
	}
};



MyEventReceiver receiver;
_device = createDevice(video::EDT_OPENGL, core::dimension2d<s32>(1024, 768),16, false, false, false,&receiver);
Any ideas?
selles
Posts: 8
Joined: Sun Jul 03, 2005 9:21 pm

Post by selles »

try to compile without pointer for IrrlichtDevice

if that don't work, here in the forum there is a structured better class, this that you are using doesn't have resources as the use of two keys simultaneously of the keyboard :wink:
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Since IEventReceiver has a pure virtual (abstract) method it can only be instantiated if all such methods have implementations. Due to your additional parameter the implementation does not match the abstract signature which is therefore still abstract. You should add a setDevice method or pass the device with an additional constructor instead.
stryker1
Posts: 5
Joined: Mon May 01, 2006 1:16 am

Thanks!

Post by stryker1 »

Yeah, that makes perfect sense. Thanks you guys.
Post Reply