Anonymous structure

Tofu Ninja via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Apr 19 10:16:00 PDT 2016


On Tuesday, 19 April 2016 at 16:16:39 UTC, ZombineDev wrote:
> On Monday, 18 April 2016 at 23:00:42 UTC, captaindet wrote:
>> On 2016-04-18 14:12, Tofu Ninja wrote:
>>> Also is there a way to have a named substructure, not a 
>>> nested structure
>>> but something to just add an additional name, maybe something 
>>> like
>>> struct a{
>>>      struct{
>>>          int x;
>>>          int y;
>>>          int z;
>>>      } b;
>>> }
>>
>> not sure what you mean by "named substructure, not a nested 
>> structure" but this works:
>>
>> struct Outer{
>> 	struct Inner{
>> 		int x;
>> 		int y;
>> 		int z;
>> 	}
>> 	Inner inner;
>> 	int a;
>> }
>>
>> Outer outer;
>> outer.a = 7;
>> outer.inner.y = 42;
>> //  outer.x = 13; //fails
>>
>> writeln(outer);
>
> There's another way:
> http://forum.dlang.org/post/n3q9vn$1l8g$1@digitalmars.com

How is that supposed to work here?


More information about the Digitalmars-d-learn mailing list