title: How to use static members as template arguments?
body: <p>I have the following code structure:</p>
  
  <h3>myClass.h</h3>
  
  <pre><code>class myClass
  {
  public:
      void DoSomething(void);
  };
  </code></pre>
  
  <h3>myClass.cpp</h3>
  
  <pre><code>#include myClass.h
  
  static const unsigned length = 5;
  static myArray&lt;float, length&gt; arrayX;
  
  void myClass::DoSomething(void)
  {
      // does something using length and array X
  }
  </code></pre>
  
  <p>Now I want to convert the static variable defined at the file scope to be static members of the class. I do the following;</p>
  
  <h3>myClass.h</h3>
  
  <pre><code>class myClass
  {
      static const unsigned length;
      static myArray&lt;float,length&gt; arrayX;
  
  public:
      void DoSomething(void);
  };
  </code></pre>
  
  <h3>myClass.cpp</h3>
  
  <pre><code>#include myClass.h
  
  const unsigned myClass::length = 5;
  myArray&lt;float, length&gt; myClass::arrayX;
  
  void myClass::DoSomething(void)
  {
      // does something using length and array X
  }
  </code></pre>
  
  <p>However, I get an error:</p>
  
  <blockquote>
    <p>C2975: 'Length' : invalid template argument for 'myArray', expected compile-time constant expression myClass.h </p>
  </blockquote>
  
  <p>I do understand I get this error because length is not initialized in the header file yet.  How can I get around this?</p>