How to implement this?

Era Scarecrow rtcvb32 at yahoo.com
Fri Apr 8 04:58:17 UTC 2022


On Friday, 8 April 2022 at 04:54:35 UTC, Era Scarecrow wrote:
> Maybe it should be `cast(A*) &b.a`?

Confusing HTML entities bit on here. Probably just ignore it.


Maybe you are doing it backwards.

What if you had

```d
struct B {
A* a;
}

A[] arraylist;
```

then in the init append a new item to A's array list, before 
doing:
```d
arraylist ~= A();
a = &arraylist[$-1];
```

Alternately, add a static list and have the batch function access 
both lists?

```d
struct B {
static A[] list;
int a_index=-1;
}

a_index=list.length;
list ~= A();
```

then reference the item by list[a_index] or something similar.


More information about the Digitalmars-d-learn mailing list