Static Constructors

Saaa empty at needmail.com
Sat Oct 4 11:00:46 PDT 2008


Can I do something like this, or should I use the static constructor for 
this?
If so, how should I set the first parameter:size ?

Fruits fruit[];


class Fruit
{
this( parameters )
{
fruit[].length=fruit[].length+1;
fruit[$-1]=this;
}
 ..
void stuff()
{
}
..
}

new fruit( .. );
new fruit( .. );

foreach (Fruit f; fruit)
{
f.stuff();
}




More information about the Digitalmars-d-learn mailing list