title: explicit instantiation of static variable of a template class in different translation units
body: <p>I was working with a template class that contains a static variable. The structure of code is as follows.</p>
  
  <h1>Header.h</h1>
  
  <pre><code>template&lt;class T&gt; class Foo
  {
  public:
      static int count;
      Foo() {
          count++;
      }
      void printCount() {
          cout &lt;&lt; count &lt;&lt; endl;
      }
  };
  template&lt;class T&gt; int Foo&lt;T&gt;::count;
  </code></pre>
  
  <h1>Source.cpp</h1>
  
  <pre><code>#include "Header.h"
  template&lt;&gt; int Foo&lt;int&gt;::count = 5;
  </code></pre>
  
  <h1>main.cpp</h1>
  
  <pre><code>#include &lt;iostream&gt;
  using namespace std;
  #include "Header.h"
  int main()
  {
      Foo&lt;int&gt; obj1;
      Foo&lt;int&gt; obj2;
      obj1.printCount();
      obj2.printCount();
      return 0;
  }
  </code></pre>
  
  <p>the output on xcode8.3.3 is:</p>
  
  <pre><code> 7
   7
  </code></pre>
  
  <p>whereas the output on Visual Studio 2015 is:</p>
  
  <pre><code>2
  2
  </code></pre>
  
  <p>i.e. the specific instantiation overrides the generic instantiation in xcode8.3.3 but not in Visual Studio 2015.
  Could someone explain this difference in behavior?
  Thanks in advance.</p>