[comp.lang.c++] Lexical scopes, inheritence, and nested type questions

Graham.Parrington@newcastle.ac.uk (Graham D. Parrington) (03/14/91)

According to the ARM (pp310) the scopes of derived and base classes
are different - however, they must be related otherwise name lookup
would not be able to find inherited attributes. The question is how
are they related? Consider the following:

struct A
{
    int a;
};

struct B : public A
{
    struct A { int ba; };
    int A();
};

struct C : public B
{
    A *p;
};


What is the type of C::p ?

As the example stands cfront2.1 chooses the global type A. This seems to
imply that the lookup of A was done at global scope (it did not find either
the type B::A or the function B::A() - which should have hidden global A if
the scope of B enclosed that of C)
Remove the function B::A() and things change, C::p now gets type B::A - ie
the nested type A
Put the function B::A() back and remove struct B::A and the example will
not compile!

These latter two results seem to imply that the lookup for A fails in C
and is continued in B - finding either the type or the function if only
one is present which seems logical. The anomoly appears to be the first 
result where despite the presence of a matching name, lookup continues to
global scope.
So, what exactly is the relationship between the scopes of A&B and B&C
and how are names supposed to be resolved in such cases?
EMAIL = Graham.Parrington@newcastle.ac.uk
POST  = Computing Laboratory, The University, Newcastle upon Tyne, UK NE1 7RU
VOICE = +44 91 222 8067		FAX = +44-91-222-8232