title: definition of static class function outside of class definition
body: <p>Consider the followin simple class definition -</p>
  
  <pre><code>    // file A.h
  #include &lt;iostream&gt;
  class A {
  public:
    static int f();
    static const int aa;
  };
  
  
      // file A.cpp
  #include "a.h"
  using namespace std;
  const   int A::aa = 10;
  int A::f() {
      return A::aa;
  }
  </code></pre>
  
  <p>And this is my main file -</p>
  
  <pre><code>    // main.cpp file
  #include "a.h"
  #include "b.h"
  using namespace std;
  const int A::aa = 100;
  int A::f();
  int main() {
      cout &lt;&lt; A::aa &lt;&lt; "\n";
      cout &lt;&lt; A::f() &lt;&lt; "\n";
  }
  </code></pre>
  
  <p>When I try to compile main.cpp, the compiler complains that the declaration of A::f() in main.cpp outside the class is a declaration, not a definition. Why is this? I do not intend to define A::f() in main.cpp. It is defined in A.cpp and the linker should link the declaration of A::f() in main.cpp with its definition in A.cpp. So I do not understand why am I getting this error. Note this is a compilation error.</p>