digitalmars.D - inner class how to explicityly access "outter this" pointer?
- d d.com (13/13) Jul 31 2005 For non-static inner class, it contains a hidden "this" pointer to the o...
- Jarrett Billingsley (2/5) Jul 31 2005 You can't, currently. This is something I also asked for a week or two ...
- Vathix (10/24) Jul 31 2005 void globalFunc(Outer o) { }
- Shammah Chancellor (4/36) Jul 31 2005 The attributes documentation lists final, but does not say what it does....
- Vathix (7/10) Jul 31 2005 It's not required here. It just means the function can't be overridden a...
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 } } }
Jul 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.
Jul 31 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); } } }
Jul 31 2005
In article <op.suszt8qol2lsvj esi>, Vathix says...On Sun, 31 Jul 2005 18:16:39 -0400, <d d.com> wrote:The attributes documentation lists final, but does not say what it does. What does it do? -ShaFor 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); } } }
Jul 31 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.
Jul 31 2005