Jos Timanta Tarigan wrote:
>
>
> hi,
>
> so im trying to create a simple class which has a static variables to
> be shared among all classes. so i create a file Control.h and came up
> with this code:
>
> #ifndef CONTROL_H
> #define CONTROL_H
>
> #include "includes.h"
>
> class Control {
> public:
>
> Control() {
> };
>
> void init() {
> for(int i = 0; i < 128; i++) g_Keys[i] = false;
> };
>
> bool getKey(int key) {
> return g_Keys[key];
> };
> void setKey(int key, bool val) {
> g_Keys[key] = val;
> };
> private:
> static bool g_Keys[128];
> };
>
> #endif
>
> but when i try to create and call the init function:
>
> Control control1();
> control1.init();
>
> it returns this errors:
>
> error: request for member 'init' in 'control1', which is of non-class
> type 'Control ()()'
>
> did i miss anything?
>
> sorry for the nooooobs question. google cant help much :(
>
>
You need to access it like this, Control::g_Keys.