Page 1 of 1

IEventReceiver interface

Posted: Mon May 01, 2006 1:23 am
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?

Posted: Mon May 01, 2006 3:36 am
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:

Posted: Mon May 01, 2006 9:38 am
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.

Thanks!

Posted: Tue May 02, 2006 1:04 am
by stryker1
Yeah, that makes perfect sense. Thanks you guys.