April 21, 2004
//works fine:
for( int i = 0; i < 2; ++i )
{
children[i] = new Node();
}

//this works, until you exit the loop/function
//then when you try to access children[0] you get an access violation
//as it has been cleaned up.
//changing child should change children[0] for example.
foreach( Node child; children )
{
child = new Node();
}


April 21, 2004
use inout

    foreach(inout Node child; children)

"Fabian Mathews" <Fabian_member@pathlink.com> wrote in message news:c64vuk$29iv$1@digitaldaemon.com...
>
> //works fine:
> for( int i = 0; i < 2; ++i )
> {
> children[i] = new Node();
> }
>
> //this works, until you exit the loop/function
> //then when you try to access children[0] you get an access violation
> //as it has been cleaned up.
> //changing child should change children[0] for example.
> foreach( Node child; children )
> {
> child = new Node();
> }
>
>