Does D have syntax for adding subscopes to classes?

sigod via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Aug 12 08:24:41 PDT 2015


On Wednesday, 12 August 2015 at 15:21:28 UTC, GregoryP wrote:
> I'm just wondering if, or how much of the following is possible 
> in some way in D:
>
> class Foo {
>     int x;
>     sub Bar {
>         int x;
>         int getFooX(){ return super.x; }
>         sub FooBar {
>             int x;
>             int y;
>             int addXes(){ return x + super.x + super.super.x; }
>         }
>     }
> }
>
> Where the Xes are accessible outside the class by Foo.x, 
> Foo.Bar.x, Foo.Bar.FooBar.x.

[Nested classes][0] maybe?

[0]: http://dlang.org/class.html#nested


More information about the Digitalmars-d-learn mailing list