Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Wrong name resolution when parent and inner class have the same name

I have an odd case with Visual Studio 2003. For somewhat legitimate reasons, I have the following hierarchy:

class A {};

class B : public A {
public:
    class A {};
};

class C : public B::A {};

That is, I have an inner class with the same name as a parent of the outer class. When C tries to inherit from B::A, Visual Studio thinks I'm pointing to the parent class A, not the nested class within B. GCC seems to resolve to the inner class version as I expected

Is this a Visual Studio 2003 bug, or am I doing it wrong? Is there a workaround (other than upgrading Visual Studio)?

like image 528
Michael Mrozek Avatar asked Aug 17 '12 16:08

Michael Mrozek


1 Answers

This looks like a bug in Visual C++ 2003. Using Visual C++ 2012, B::A correctly names the nested class A, not the base class A.

like image 185
James McNellis Avatar answered Oct 16 '22 19:10

James McNellis