title: Why is a static member function _declared_ static, but _defined_ otherwise in C++?
body: <p>Here's a minimal working example:</p>
  
  <p>A.h:</p>
  
  <pre><code>class A{
          static int a_member_function();
  };
  </code></pre>
  
  <p>A.cpp</p>
  
  <pre><code>#include "A.h"
  int A::a_member_function(){return 5;}
  
  
  int main(){ return 1;}
  </code></pre>
  
  <p>This code compiles and runs, but, it seems to me that:</p>
  
  <pre><code>static int A::a_member_function(){return 5;}
  </code></pre>
  
  <p>could just as easily be used to define the static member function of class A. Indeed, it seems like it could actually be rather useful to have this requirement, since it would remind the reader of the .cpp file that a_member_function is static.</p>
  
  <p>However, this clearly doesn't work:</p>
  
  <pre><code>error: cannot declare member function ‘static int A::a_member_function()’ to have static linkage [-fpermissive]
  </code></pre>
  
  <p>So <em>why</em> doesn't it work? What's the reasoning behind this decision? </p>