title: unresolved external symbol when static variable is defined inside the class declaration
body: <p>I am going to get right to the point:</p>
  
  <pre><code>//ComponentHolder.h
  
  template&lt;class Holder, uint ID&gt;
  class TemplateComponentHolder : public ComponentHolderInterface {
  protected:
      std::vector&lt;ComponentType*&gt; mComponents;
  
  
  public:
     TemplateComponentHolder() : ComponentHolderInterface(ID) {}
  
     static const uint getStaticID() { return ID; }
  };
  
  class ConcereteComponentHolder1 : public TemplateClassHolder&lt;ComponentType, 1000&gt; {
  public:
      inline void print() { std::cout &lt;&lt; "test"; }
  };
  
  //World.h
  class World {
  private:
     std::map&lt;uint, ComponentHolderInterface*&gt; mHolders;
  public:
     template&lt;class Holder&gt; Holder * getHolder() {
         auto i = mHolders.find(Holder::getStaticID());
         if(i != mHolders.end())
            return static_cast&lt;Holder*&gt;((*i));
         return NULL;
     }
  
     /* ... */
  };
  
  //Main code
  int main() {
    World * world = new World;
    world-&gt;addHolder(new ConcerteComponentHolder1);
  
    world-&gt;getHolder&lt;ConcreteComponentHolder1&gt;()-&gt;print();
  }
  </code></pre>
  
  <p>I get unresolved external symbol error. Says cannot resolve "ConcereteComponentHolder1::ID". If I change the static variable to non const and add it to a source file:</p>
  
  <pre><code>//ComponentHolder.cpp
  uint ConcreteComponentHolder1::ID = 1000;
  </code></pre>
  
  <p>There is no problem. It makes sense why the latter one must be defined explicitly. But when I am using <code>const</code>, I have to define it in the header. Getting a linker error when using const just doesn't make sense. Is it because of the template function being generated in the header? Or is it something else?</p>