why do you want to define it static?
Remove the static and it'll work great.
If you want it shared between *all* classes, just make it a global variable.


Thanks,
Tyler Littlefield
Web: tysdomain.com
email: [email protected]
My programs don't have bugs, they're called randomly added features.

  ----- Original Message ----- 
  From: Jos Timanta Tarigan 
  To: [email protected] 
  Sent: Sunday, April 05, 2009 3:28 PM
  Subject: [c-prog] noob question: implementation in header



  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 :(



  

[Non-text portions of this message have been removed]

Reply via email to