nested class inheritance
Christophe Travert
travert at phare.normalesup.org
Fri Jul 13 11:53:24 PDT 2012
"Era Scarecrow" , dans le message (digitalmars.D:172269), a écrit :
> class Fruit {
> int x;
> class Seed {
> void oneMoreToX() {
> x++; //knows about Fruit.x, even if not instantiated
> }
> }
>
> static class Seed2 {
> void oneMoreToX() {
> // x++; //fails to compile, no knowledge of Fruit
> }
> }
> }
>
> class Apple: Fruit {
> class AppleSeed: Fruit.Seed { } //fails (no outer object
> (Fruit.x) and makes no sense)
> class AppleSeed2: Fruit.Seed2 { } //works fine
> }
AppleSeed does have a outer Fruit, and this Fruit happens to be an
Apple. I don't see what is the issue, and what prevents the langage to
support such AppleSeed. I'm not saying there is nothing that prevents
the langage to support such pattern, I am not used to inner classes.
Pleas enlighten me.
More information about the Digitalmars-d
mailing list