Re: How does an inner class (non-static) refer to members of it's enclosing class?
Mott@nospam.UNM.edu (Wolfgang) writes:
> What does that look like in practice?
In Sun's implementation all constructors of the inner class get passed
an extra parameter of the outer class' type, which is assigned to an
autogenerated variable called this$0.
> How does an inner class refer to members of it's enclosing class?
Via a "typed this", that is e.g. Outer.this.member, which is turned
into this$0.member by the compiler.
> And what happens when an inner class member has the same name as a
> member of the enclosing class?
The two are distinct because they are in different classes. When
resolving they follow normal namespace rules, that is an unqualified
reference will be the same as a this-reference, where this is the
inner-class type object.
|All times are GMT. The time now is 10:09 AM.|
Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.