nested class inheritance

Gor Gyolchanyan gor.f.gyolchanyan at gmail.com
Fri Jul 13 12:22:27 PDT 2012


On Fri, Jul 13, 2012 at 11:18 PM, Christophe Travert <
travert at phare.normalesup.org> wrote:

> Andrei Alexandrescu , dans le message (digitalmars.D:172280), a écrit :
> >> For Fruit.Seed it's Fruit, for AppleSeed it's Apple. This makes sense
> >> because the Apple, which AppleSeed sees is the same object, which
> >> Fruit.Seed sees as it's base type Fruit.
> >
> > That would mean AppleSeed has two outer fields: a Fruit and an Apple.
>
> Only one. Apple. And when AppleSeed.super seed this Apple, it sees a
> fruit.
>
> AppleSeed a;
> assert(is(typeof(a.outer) == Apple));
> assert(is(typeof(a.super) == Seed));
> assert(is(typeof(a.super.outer) == Fruit));
> //but:
> assert(a.outer is a.super.outer);
>
> If you can't figure out how can a.outer and a.super.outer have two
> different types, but be the same, think about covariant return.
>
>
>
Exactly!

-- 
Bye,
Gor Gyolchanyan.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20120713/1e02c2a0/attachment.html>


More information about the Digitalmars-d mailing list