title: Static or nonstatic getters/setters for static class variable in C++
body: <p>Suppose I have the following class:</p>
  
  <pre><code>class A {
  private:
      static double X;
  };
  
  double A::X = 0.0;
  </code></pre>
  
  <p>The variable <code>A::X</code> really ought to be static, because all instances of <code>A</code> must, in the context I'm concerned with, share the same value of <code>A::X</code>.  </p>
  
  <p>Now, my question is whether to make getter and setter functions for <code>A::X</code> static.  They will be defined like this:</p>
  
  <pre><code>void A::setValue(const double x) {
  #pragma omp critical
  {
      if(x&lt;0.0||x&gt;1.0)
          // custom macro call to raise exception
  
      X = x;
  }
  }
  
  double A::getValue() {
  #pragma omp critical
  {
      return X;
  }
  }
  </code></pre>
  
  <p>It seems to me that it makes absolutely no practical difference whether I add these getter and setter functions to <code>A</code> as static or as nonstatic member functions.  Is this right?</p>
  
  <p>In this example, or more generally, what reasons might there be to prefer that such getter and setter functions be made static or nonstatic members of the class whose static member they control access to?</p>