I cannot understand why this piece of code does not compile:
namespace A {
class F {}; // line 2
class H : public F {};
}
namespace B {
void F(A::H x); // line 7
void G(A::H x) {
F(x); // line 9
}
}
I am using gcc 4.3.3
, and the error is:
s3.cpp: In function ‘void B::G(A::H)’:
s3.cpp:2: error: ‘class A::F’ is not a function,
s3.cpp:7: error: conflict with ‘void B::F(A::H)’
s3.cpp:9: error: in call to ‘F’
I think that because in line 9 there is no namespace prefix, F(x)
should definitively mean only B::F(x)
. The compiler tries to cast x
into its own superclass. In my understanding it should not. Why does it do that?