Why no acess to other structs in classes?

John Demme me at teqdruid.com
Sun Nov 5 09:23:52 PST 2006


Karen Lanrap wrote:

> class C
> {
>     struct S
>     {
>         uint data;
>     }
>     S s;
>     struct T
>     {
>         uint f()
>         {
>             return s.data;
>             // this for s needs to be type C not type T *
>         }
>     }
> }
> void main(){}


Actually, it's more generic than that- the inner struct can't access any
member variable of the outer class:

class C
{
    uint s;
    struct T
    {
        uint f()
        {
            return s;
            // this for s needs to be type C not type T *
        }
    }
}

void main(){}

I'm not certain if this is a bug or if there is a good reason for this.

-- 
~John Demme
me at teqdruid.com
http://www.teqdruid.com/



More information about the Digitalmars-d-learn mailing list