Confused about Inner Classes

Janice Caron caron800 at googlemail.com
Sun Oct 21 14:18:13 PDT 2007


Just trying to get my head around inner classes (a new concept for me).

OK, so inner classes get a hidden "context pointer" to the enclosing
instance. So far so good. But how does that interoperate with
inheritance. For example:

class Outer
{

    class InnerA
    {
    }

    class InnerB : InnerA
    {
    }
}

Is it the case that InnerB has both a super class (InnerA) and an
outer class (Outer), and, further, that it's super class has an outer
class (also Outer)? So an instance of InnerB can refer to "outer",
"super" and "super.outer" (where "outer" and "super.outer" are the
same thing?)

Let's get even more bizarre:

class OuterA
{
    class Inner A
    {
    }
}

class VeryConfused : OuterA.InnerA
{
}

I'm not sure that even makes sense. It's very hard to wrap my head
around. Is that nonsense?

What are inner classes good for anyway?



More information about the Digitalmars-d mailing list