title: C++ class with static pointer
body: <p>I don't understand pointers and references very well yet, but I have a class with static methods and variables that will be referenced from main and other classes. I have a variable defined in main() that I want to pass to a variable in this class with static functions. I want those functions to change the value of the variable that is seen in the main() scope.</p>
  
  <p>This is an example of what I am trying to do, but I get compiler errors...</p>
  
  <pre><code>class foo
  {
      public:
  
      static int *myPtr;
  
      bool somfunction() {
          *myPtr = 1;
          return true;
      }
  };
  
  int main()
  {
      int flag = 0;
      foo::myPtr = &amp;flag;
  
      return 0;
  }
  </code></pre>