在头文件中初始化我得到以下错误:
invalid in-class initialization of static data member of non-integral type 'bool [8]'
如果我尝试在 .cpp 中初始化,我得到:
'bool Ion::KeyboardInput::key [8]' is a static data member; it can only be initialized at its definition
继承人的标题:
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};
};