Consider this code:
struct A
{
void foo() const
{
std::cout << \"const\" << std::endl;
}
private:
void foo()
The technical reason has been answered by other answers. I'll only focus on this question:
In other words why overload resolution comes 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.
That's how the language was designed. The intent is trying to call the best viable overload, as far as possible. If it fails, an error will be triggered to remind you to consider the design again.
On the other hand, suppose your code compiled and worked well with the const member function being invoked. Someday, someone (maybe yourself) then decides to change the accessibility of the non-const member function from private to public. Then, the behavior would change without any compile errors! This would be a surprise.