title: Declare the same identifier as const variable and member function
body: <p>I have wrote the following piece of code</p>
  
  <pre><code>#include &lt;iostream&gt;
  const int N = 5;
  class X
  {
    public:
    int array[N];
    void foo()
    {
       std::cout &lt;&lt; "array size:"&lt;&lt;sizeof(array)/N &lt;&lt; std::endl;   
    }
    enum
   {
     N = 3    
    };
  };
  
  int main()
  {
    X x;
    x.foo();
  } 
  </code></pre>
  
  <p>The aforementioned code does not compile with GCC:</p>
  
  <pre><code>&lt;source&gt;:13:8: error: declaration of 'N' [-fpermissive]
      N = 3
          ^
  &lt;source&gt;:2:11: error: changes meaning of 'N' from 'const int N' [-fpermissive]
   const int N = 5;
             ^
  </code></pre>
  
  <p>From my point  in compile time the array is defined as an array of five integers and N is defined as 5.  How the compiler resolved the name declaration of variables?</p>