Here are some contrived code examples:
template<typename T> void Do(T arg) { (void)arg->b; } namespace A { struct Foo { int a; }; } namespace B { struct Foo { int b; }; struct Bar : A::Foo { void Blah() { Do((Foo *)0); } }; }
What when compiling with gcc 4.8.2 (clang gives a similar error):
namespacebug.cpp: In instantiation of 'void Do(T) [with T = A::Foo*]': namespacebug.cpp:10:34: required from here namespacebug.cpp:1:39: error: 'struct A::Foo' has no member named 'b' template<typename T> void Do(T arg) { (void)arg->b; } ^
Note that in the error this applies to T = A::Foo , although on the call site I create Foo in the namespace B If I remove the base class decl ( : A::Foo ), then everything compiles fine.
Does this seem to suggest that inheriting from A::Foo somehow brings it into my namespace and maps it to my use of Foo ? What is a C ++ "function"?
(Of course, this problem can be easily fixed with the namespacing of my use of Foo , but that is not a question.)
c ++ namespaces
Aardappel
source share