title: "does not name a type" error when using namespaces in c++
body: <p>In the below code writing the statement <code>A::x=5</code> is giving the error:</p>
  
  <blockquote>
    <p>'x' in namespace 'A' does not name a type </p>
  </blockquote>
  
  <p>Can't we assign a value globally for <code>x</code> variable?</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  int x = 10;  
  
  namespace A
  {
      int x = 20; 
  }
  
  A::x=5;
  
  int main()
  {
      int x = 30; 
      std::cout &lt;&lt; "x = " &lt;&lt; x &lt;&lt; std::endl;
      std::cout &lt;&lt; "A::x = " &lt;&lt; A::x &lt;&lt; std::endl;
      std::cout &lt;&lt; "::x = " &lt;&lt; ::x &lt;&lt; std::endl;
  }
  </code></pre>