Initialise dynamic array in array of structures

Paul via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Jun 21 12:15:56 PDT 2016


Given these structures and declaration:

struct CoordList{
         int x, y;
}

struct Part{
	int x, y;
	CoordList[] coords;
	int nextNode, prevNode;
	string nextEnter, prevEnter;
}

Part[10] trackTemplates;


Can someone please tell me why I can't initialise Part[0].coords 
like this:

trackTemplates[0].coords = [ {0, 9}, {1, 1}, {3, 6} ];

but I can do this:

CoordList[] temp = [ {0, 9}, {1, 1}, {3, 6} ];
trackTemplates[0].coords = temp;

Many thanks!






More information about the Digitalmars-d-learn mailing list