Accessing outer class attribute from inner struct
Andre Pany via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Tue Aug 29 00:59:40 PDT 2017
On Monday, 28 August 2017 at 23:12:40 UTC, Moritz Maxeiner wrote:
>
> In both cases S doesn't inherently how about C, which means a
> solution using default initialization is not feasible, as
> S.init can't know about any particular instance of C.
> I don't think there's any way for you to avoid using a class
> constructor.
Thanks for the explanation. I now tried to use a class and use a
static opIndex. But it seems from a static method you also cannot
access the attributes of a outer class :)
class TCustomGrid: TCustomPresentedScrollBox
{
class ColumnsArray
{
static TColumn opIndex(int index)
{
// Reference is defined in TCustomGrid via inheritene
int r = getIntegerIndexedPropertyReference(reference,
"Columns", index);
return new TColumn(r);
}
}
alias Columns = ColumnsArray;
...
}
This seems like an unnecessary limitation...
Kind regards
André
More information about the Digitalmars-d-learn
mailing list