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

captain_fid bell.hue at gmail.com
Thu Mar 6 11:31:52 PST 2014


On Thursday, 6 March 2014 at 19:19:29 UTC, captain_fid wrote:
> Sorry for the very basic question. Much still alludes me with 
> this language. I appreciate the forum.
>
> struct S
> {

Wow sorry for that. I'm a moron... don't press <tab> <enter>...

struct S
{
   int a;
   string b;
}

class A
{
   S[]* pointer_to_list;
   abstract...
}

class B: A
{
   S[] items = [ {10, "first"}, {20, "second"}];

   this() {
    pointer_to_list = &items;
   }
}

My problem is in de-referencing later (seg fault). Is this even 
the best way?

I Really need to access the array in a derived class. 'S' (I 
believe) really is best as a Structure.

Any suggestions. Thanks in advance (and sorry for the rough 
start).




More information about the Digitalmars-d-learn mailing list