Namespace search order
<p>I have two namespaces that each have a function with the same name. If from one of the namespaces I want to call the function that matches the best. From a function in NamespaceA, if I call MyFunction(...), of course it uses the one in NamespaceA. However, if I add a 'using NamespaceB::MyFunction', I would then expect the behavior I described. However, what I actually see is that it ALWAYS finds the NamespaceB function, even though I am in NamespaceA. HOWEVER, if I ALSO add a using::NamespaceA (even though I am already in NamespaceA), it works as I'd expect. A demonstration is below. Can anyone explain how this works?</p>

<pre><code>#include &lt;iostream&gt;

namespace NamespaceA
{
  void DoSomething();
  void MyFunction(int object);
}

namespace NamespaceB
{
  void MyFunction(float object);
}

namespace NamespaceA
{
  void DoSomething()
  {
    using NamespaceA::MyFunction; // Note that without this line the lookup always fins the NamespaceB::MyFunction!
    using NamespaceB::MyFunction;

    MyFunction(1);
    MyFunction(2.0f);
  }

  void MyFunction(int object)
  {
    std::cout &lt;&lt; "int: " &lt;&lt; object &lt;&lt; std::endl;
  }
}

namespace NamespaceB
{
  void MyFunction(float object)
  {
    std::cout &lt;&lt; "float: " &lt;&lt; object &lt;&lt; std::endl;
  }
}

int main(int argc, char *argv[])
{
  NamespaceA::DoSomething();

  return 0;
}
</code></pre>
