Problems with Array Assignment?
Samwise via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Wed May 10 10:26:09 PDT 2017
On Wednesday, 10 May 2017 at 13:43:54 UTC, Adam D. Ruppe wrote:
> In your code, I see one big mistake:
>
> ---
> class TileRenderer
> {
> private Tile[] tiles;
> /*...*/
> }
>
> class CTileRenderer : TileRenderer
> {
> private CTile[] tiles;
> /*...*/
> }
> ---
>
>
> Those are two separate arrays! Stuff examined through
> TileRenderer will be looking at a different array than looking
> through CTileRenderer.
I wondered about that when I did it, but I assumed (wrongly) that
since the name of the array was the same, it would override it.
Thank you for suggesting that I make rendering a tile's
responsibility instead of the renderer's. It honestly makes more
sense that way, and my code is cleaner because of it. I did
actually get it working because of that.
Just to clarify, you can use a superclass variable to reference a
member of a subclass? That seems to be what's happening.
Thanks so much guys, I really appreciate it. My code it working
now, and it's committed to github, so you can check it out if
you'd like. Thanks!
~Sam
More information about the Digitalmars-d-learn
mailing list