Confused about Inner Classes
Bruce Adams
tortoise_74 at yeah.who.co.uk
Mon Oct 22 03:57:40 PDT 2007
Jarrett Billingsley Wrote:
> "Janice Caron" <caron800 at googlemail.com> wrote in message
> news:mailman.494.1193001500.16939.digitalmars-d at puremagic.com...
> > 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:
> >
Hi,
Just to check something here. I may be having a stupid day here. Are you saying there is a pointer member available from any inner class to the outer? This sounds like a useful feature in certain circumstances but not one I've heard of before. When using inner classes in C++ I have to explicitly provide a pointer to the outer class. It looks like D does D do this for us (
http://www.digitalmars.com/d/class.html
). But it also looks like the outer class always has at least one instance of the inner class. In C++ I often declare helper types nested within other classes but I do not expect to have an instance of them created for me. This suggests that a D best coding practice is to make helper types a member of the same module but never nest them. Otherwise, how do I declare something other than a 1-to-1 relationship with a nested class?
Regards,
Bruce.
More information about the Digitalmars-d
mailing list