gcc error for Name lookup. - Item 32 exception C++

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,149
Latest member
Vinay Kumar Nevatia0
Top