nested class inheritance

Simen Kjaeraas simen.kjaras at gmail.com
Tue May 31 14:24:31 PDT 2011


On Tue, 31 May 2011 20:17:23 +0200, Michael Shulman  
<viritrilbia at gmail.com> wrote:

> I have thought of a workaround with 'alias this':
>
> class Outer2 : Outer1 {
>   class Inner2 {
>     Inner1 _self;
>     alias _self this;
>     this() {
>       _self = this.outer.new Inner1();
>     }
>   }
> }
>
> This seems to work, but requires manually calling all the constructors
> of Inner1 from corresponding constructors of Inner2.  Is there a better
> way to do what I am after?

Does your inner class require implicit access to the outer class? That is,
could a static inner class work? Example:


class A {
     static class AA {
     }
}

class B : A {
     static class BB : A.AA {
     }
}


-- 
   Simen


More information about the Digitalmars-d-learn mailing list