I have the following set of classes (minimal replication of my real situation):
namespace Parent { class A {}; namespace Nested { class A {}; } template <typename T> class B { A myA; }; }
I would expect the member Parent::B::myA to be uniquely resolved as a type of Parent::A However, elsewhere in my project, I have the following:
namespace Parent { using namespace Nested; void foo() { B<int> myB; } }
which does not compile in MSVC 2003:
error C2872: 'A' : ambiguous symbol could be 'Test.cpp(5) : Parent::A' or 'Test.cpp(9) : Parent::Nested::A' Test.cpp(26) : see reference to class template instantiation 'Parent::B<T>' being compiled with [ T=int ]
The code will be compiled if I am explicit in my B::myA , i.e. Parent::A myA; . However, the code compiles since it is under gcc-4.3.4 . Is this just a bug with MSVC 2003, or do I really need to worry about the area in which my templates can be created?
source share