title: Why is a public const method not called when the non-const one is private?
body: <p>Consider this code:</p>
  
  <pre><code>struct A
  {
      void foo() const
      {
          std::cout &lt;&lt; "const" &lt;&lt; std::endl;
      }
  
      private:
  
          void foo()
          {
              std::cout &lt;&lt; "non - const" &lt;&lt; std::endl;
          }
  };
  
  int main()
  {
      A a;
      a.foo();
  }
  </code></pre>
  
  <p>The compiler error is:</p>
  
  <blockquote>
    <p>error: 'void A::foo()' is private`.</p>
  </blockquote>
  
  <p>But when I delete the private one it just works. Why is the public const method not called when the non-const one is private?</p>
  
  <p>In other words, why does overload resolution come before access control? This is strange. Do you think it is consistent? My code works and then I add a method, and my working code does not compile at all.</p>