User defined types: Problems with ref

FreeSlave freeslave93 at gmail.com
Thu Jan 23 16:31:25 PST 2014


On Thursday, 23 January 2014 at 15:24:19 UTC, Chris wrote:
> Thanks, that was fast! Yes I was tinkering around with 
> pointers, but didn't get it right, you did. However, the output 
> is still the same, i.e. two different sets:
>
> // After creating and changing
> <div id="1">
> Hello, world!
> <span>
> </span>
> </div>
>
> // The Elements in Tree.elements:
> [<div>
> </div>
> , <span>
> </span>
> ]

Maybe more code will explain more.

Note that array requires data to be continuous, so if there are 
no space for new element, it reallocates the whole chunk and 
therefore invalidates old pointers. Use linked list or replace 
struct with class.


More information about the Digitalmars-d-learn mailing list