Thread overview | |||||||||
---|---|---|---|---|---|---|---|---|---|
|
July 31, 2005 inner class how to explicityly access "outter this" pointer? | ||||
---|---|---|---|---|
| ||||
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 Re: inner class how to explicityly access "outter this" pointer? | ||||
---|---|---|---|---|
| ||||
Posted in reply to d | <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 Re: inner class how to explicityly access "outter this" pointer? | ||||
---|---|---|---|---|
| ||||
Posted in reply to d | 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 Re: inner class how to explicityly access | ||||
---|---|---|---|---|
| ||||
Posted in reply to Vathix | 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 Re: inner class how to explicityly access | ||||
---|---|---|---|---|
| ||||
Posted in reply to Shammah Chancellor | > 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.
|
Copyright © 1999-2021 by the D Language Foundation