Re: help with c++ namespace visibility rules problem

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Oct 9, 2008 at 14:29, David Mansfield <david@xxxxxxxxxx> wrote:
> namespace n1 {
>  class C {};
>  void f(C& c) {}
> }
>
> namespace n2 {
>  using n1::C;
>  void f(C& c) {}
> }
>
> using namespace n2;
>
> void foo(C& c)
> {
>  f(c);
> }
>
> Why won't it automatically use n2::f() in this case?  What makes this
> ambiguous?  Should the n1 namespace be hidden unless I'm "using" it?
>

C is defined in n1, so Argument-Dependant Lookup (aka Koenig Lookup)
will find the f in n1, and the using directive means it also finds the
f in n2.

HTH,
~ Scott

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux