title: C++ namespace and const variable
body: <p><em>I compile those files as single program with Visual studio 2019 in win10</em></p>
  <p>My project have just two source files:</p>
  <p>/**** a.cpp  ****/</p>
  <pre><code>namespace pers{
      const int LEN = 5;
  }
  </code></pre>
  <p>/**** b.cpp  ****/</p>
  <pre><code>namespace pers {
      const int LEN = 5;
  }
  
  int main() {
      return 0;
  }
  </code></pre>
  <p>It can be compiled successfully.But I dont konw why? I defined <code>LEN</code> twice!!</p>
  <p>so, I delete the <code>const</code> :</p>
  <p>/**** a.cpp  ****/</p>
  <pre><code>namespace pers{
      int LEN = 5;
  }
  </code></pre>
  <p>/**** b.cpp  ****/</p>
  <pre><code>namespace pers {
      int LEN = 5;
  }
  
  int main() {
      return 0;
  }
  </code></pre>
  <p>Now it doesn't work!
  So, my question is what happend? <code>const</code> variable in diffierent source files can be defined twice or more (means NO multi-definition error) .</p>
  <p>Meanwhile, compiler will throw &quot;multi-definition error&quot; if do this:</p>
  <pre><code>namespace pers {
      const int LEN = 5;
      const int LEN = 5; // multi-definition error
  
      const int LEN2 = 10;
  }
  namespace pers {
      const int LEN2 = 10; // multi-definition error
  }
  
  
  int main() {
      const int a = 10;
      const int a = 10; // multi-definition error
  
      return 0;
  }
  </code></pre>