Best way to reference an array in a child class...

captain_fid bell.hue at gmail.com
Thu Mar 6 14:05:12 PST 2014


On Thursday, 6 March 2014 at 21:26:11 UTC, Ali Çehreli wrote:
> On 03/06/2014 12:02 PM, Steven Schveighoffer wrote:
>
> > The best way
> > to reference an array in a child class, especially one of a
> static type,
> > is to not have another copy in the child class :)
>
> Agreed. Alternatively, a member function in the child class 
> could return a slice.
>
> Ali

Steve, thanks for the link and the nicely written article. Also 
for the assessment on pointer syntax, I'd love to avoid if 
possible (especially w/ limitations you noted).

I had been spending time over at http://dlang.org/arrays.html and 
had forgotten (or never understood) dynamic arrays were passed by 
slices. That link only talks about passing static arrays (IIRC). 
Keeping track of 'what being passed how' is tough for this 
programmer.

Your suggestion Ali (of not accessing the base member in the 
child was great) and it works properly.

Believe if I understand what you are suggesting above is never to 
have the array in base? simply retrieve slice through the child 
member function?


More information about the Digitalmars-d-learn mailing list