Getting 'this' of outer class?
Jarrett Billingsley
kb3ctd2 at yahoo.com
Sun Feb 19 08:27:53 PST 2006
"Nick" <Nick_member at pathlink.com> wrote in message
news:dta0ca$2d3p$1 at digitaldaemon.com...
> I'm sort of new to the inner class concept. I know the inner class has
> access to
> the outer class through a 'hidden' this reference, but how do I access
> this
> reference directly? Say I have the following:
>
> # class A
> # {
> # class B
> # {
> # B getB() { return this; } // Ok
> # A getA() { return ???; } // How do I do this?
> # }
> # }
>
> Right now I'm stuck with adding a private getThis() member to A...
I don't think you can, not in the current implementation of inner classes,
at least. There's probably a way to hack the inner class reference to get
at the outer class reference, but it's probably not recommended ;) I agree
that it'd be very nice to have. It's kind of like not being able to get the
context pointer of delegates (which, according to Walter, are similar to how
inner classes are implemented).
More information about the Digitalmars-d-learn
mailing list