D - [BUG] foreach with new
- Fabian Mathews (13/13) Apr 20 2004 //works fine:
- Matthew (4/17) Apr 20 2004 use inout
//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();
}
Apr 20 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();
}
Apr 20 2004








"Matthew" <matthew.hat stlsoft.dot.org>