Thread overview
inner class how to explicityly access "outter this" pointer?
Jul 31, 2005
d
Aug 01, 2005
Vathix
Re: inner class how to explicityly access
Aug 01, 2005
Shammah Chancellor
Aug 01, 2005
Vathix
July 31, 2005
For non-static inner class, it contains a hidden "this" pointer to the outter, how can I expplicitly access it?  Thanks.

e.g.

void globalFunc(Outter o) {
o.blah ...;
}

class Outter {

class Inner {

void foo() {
globalFunc(???)  // how to explicityly access "outter this" pointer
}

}

}



July 31, 2005
<d@d.com> wrote in message news:dcjik7$u6t$1@digitaldaemon.com...
> For non-static inner class, it contains a hidden "this" pointer to the
> outter,
> how can I expplicitly access it?  Thanks.

You can't, currently.  This is something I also asked for a week or two ago.


August 01, 2005
On Sun, 31 Jul 2005 18:16:39 -0400, <d@d.com> wrote:

> For non-static inner class, it contains a hidden "this" pointer to the outter,
> how can I expplicitly access it?  Thanks.
>
> e.g.
>
> void globalFunc(Outter o) {
> o.blah ...;
> }
>
> class Outter {
>
> class Inner {
>
> void foo() {
> globalFunc(???)  // how to explicityly access "outter this" pointer
> }
>
> }
>
> }
>

void globalFunc(Outer o) { }

class Outer
{
   final Outer outer() { return this; }

   class Inner
   {
      void foo() { globalFunc(outer); }
   }
}
August 01, 2005
In article <op.suszt8qol2lsvj@esi>, Vathix says...
>
>On Sun, 31 Jul 2005 18:16:39 -0400, <d@d.com> wrote:
>
>> For non-static inner class, it contains a hidden "this" pointer to the
>> outter,
>> how can I expplicitly access it?  Thanks.
>>
>> e.g.
>>
>> void globalFunc(Outter o) {
>> o.blah ...;
>> }
>>
>> class Outter {
>>
>> class Inner {
>>
>> void foo() {
>> globalFunc(???)  // how to explicityly access "outter this" pointer
>> }
>>
>> }
>>
>> }
>>
>
>void globalFunc(Outer o) { }
>
>class Outer
>{
>    final Outer outer() { return this; }
>
>    class Inner
>    {
>       void foo() { globalFunc(outer); }
>    }
>}

The attributes documentation lists final, but does not say what it does.  What does it do?

-Sha


August 01, 2005
> The attributes documentation lists final, but does not say what it does.  What
> does it do?
>

It's not required here. It just means the function can't be overridden and doesn't need to be virtual unless it's overriding something. Non-virtual has a bit (a lot?) of a performance gain.

It's probably better to not use final in this case since you might want to override it in a derived class with a covariant (the derived type) return type. But sometimes I'll choose final if I don't expect to derive from the class, like if it's a private class.