Page 1 of 1

cannot instantiate abstract class error

Posted: Fri Dec 28, 2007 10:18 pm
by alfabeta90
Got a 'MyEventReceiver' : cannot instantiate abstract class error when paste following code:

Before main:

Code: Select all

class MyEventReceiver : public IEventReceiver 
{
public:
  virtual bool OnEvent(SEvent event) 
  {
    if (event.KeyInput.Key == KEY_KEY_S && event.KeyInput.PressedDown) 
	{
		cout << "PRESED S\n";
	    return true;
    }
    return false;
  }
};
Into main:

Code: Select all

MyEventReceiver receiver;
	IrrlichtDevice *device = createDevice(video::EDT_DIRECT3D9, core::dimension2d<s32>(800, 600),32, false, false, false,&receiver);
Tenks for answer.

Posted: Fri Dec 28, 2007 10:24 pm
by hybrid
If you use Irrlicht 1.4 you have to make the parameter of OnEvent a const-ref: (const SEvent& event)