Say you have a class with a struct inside, like so:
class A
{
struct B
{
int fork() { return 5; }
}
}
You can then access B's members using:
A a=new A;
writefln(a.B.fork());
This is fine.
However, if I want to have an array of nested structs..
class A
{
struct B
{
int fork() { return 5; }
}
B[5] b;
}
You can easily access this array as you would expect:
A a=new A;
writefln(a.b[0].fork());
But you can still access the class definition:
writefln(a.B.fork());
Normally in C++, I'd use the struct{...} b[5];
syntax, but that isn't available in D.
I've also tried to make the struct private (and yes, the class is in a
separate module), and I can still access it.
Is there any way to have an array of nested structs without being able to
access the definition? Putting the struct outside the class is not
possible, as the struct depends upon access to the class's
methods.