array setting with objects (bug?)

Jarrett Billingsley kb3ctd2 at yahoo.com
Tue Mar 4 05:53:35 PST 2008


"Denton Cockburn" <diboss at hotmail.com> wrote in message 
news:pan.2008.03.04.13.32.00.785638 at hotmail.com...

> arr[] = new C; /* this is the offending line, it doesn't happen if I */

This creates *one* instance of C and sets all the elements of arr to point 
to that single instance.

Hence:

> [5]
> [5,5]
> [5,5,5]

You keep modifying the same array.  :) 





More information about the Digitalmars-d mailing list