Initialization in the header file causes the following error:
invalid in-class initialization of static data member of non-integral type 'bool [8]'
if I try to initialize in .cpp, I get:
'bool Ion::KeyboardInput::key [8]' is a static data member; it can only be initialized at its definition
Here is the title:
enum MYKEYS { KEY_UP, KEY_DOWN, KEY_LEFT, KEY_RIGHT, KEY_W, KEY_S, KEY_A, KEY_D }; class KeyboardInput { public: KeyboardInput(); ~KeyboardInput(); static void getKeysDown(ALLEGRO_EVENT ev); static void getKeysUp(ALLEGRO_EVENT ev); static bool getKey(int keyChoice); private: static bool key[8] = {false, false, false, false, false, false, false, false}; };
source share