Inner struct accessing host member

abanstadya via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Aug 5 15:14:22 PDT 2014


On Tuesday, 5 August 2014 at 20:32:08 UTC, Philippe Sigaud wrote:
> I'd have thought that this would work:
>
> struct A
> {
>     int[] i;
>     B b;
>
>     struct B
>     {
>         void foo() { i ~= 1;}
>     }
> }
>
> void main()
> {
>     A a;
>     a.b.foo();
> }
>
> But the compiler tells me 'need this for i of type int[]'.
> Is there any way I can gain access on i inside B?

programming Q, either youra newb or not, should rather be posted 
to 'http://forum.dlang.org/group/digitalmars.D.learn'. Your post 
appears on 'http://forum.dlang.org/group/digitalmars.D' which is 
more related to the lang. design rather to programming Q. Take 
care next time bro.



More information about the Digitalmars-d-learn mailing list