K
ketan
Hi,
While understanding name lookup using item 32 of EC++ ( Sutter ), i
found error
from gcc bit unclear. It will be great if anyone can help me.
In short - compiler complains about reference while there is no
reference in signature.
Code
-----------------------------------------------------
namespace A{
class X{};
void f(X);
}
namespace B{
void f( A::X ) {}
void g( A::X param)
{
f(param);
}
}
int main()
{
A::X xc;
B::g(xc);
}
----------------------------------------
lookup.cpp: In function `void B::g(A::X)':
lookup.cpp:10: error: call of overloaded `f(A::X&)' is ambiguous
<----------- ??? HOW?
lookup.cpp:7: error: candidates are: void B::f(A::X)
lookup.cpp:3: error: void A::f(A::X)
so the error is consistent according to lookup rules, but I am
surprised at 2nd line
of error. ( gcc - 3.3.1 on Sun)
WHy it shows f(A::X&) ? -- is by reference understood from the code or
something else ?
thanks
Ketan
While understanding name lookup using item 32 of EC++ ( Sutter ), i
found error
from gcc bit unclear. It will be great if anyone can help me.
In short - compiler complains about reference while there is no
reference in signature.
Code
-----------------------------------------------------
namespace A{
class X{};
void f(X);
}
namespace B{
void f( A::X ) {}
void g( A::X param)
{
f(param);
}
}
int main()
{
A::X xc;
B::g(xc);
}
----------------------------------------
lookup.cpp: In function `void B::g(A::X)':
lookup.cpp:10: error: call of overloaded `f(A::X&)' is ambiguous
<----------- ??? HOW?
lookup.cpp:7: error: candidates are: void B::f(A::X)
lookup.cpp:3: error: void A::f(A::X)
so the error is consistent according to lookup rules, but I am
surprised at 2nd line
of error. ( gcc - 3.3.1 on Sun)
WHy it shows f(A::X&) ? -- is by reference understood from the code or
something else ?
thanks
Ketan