dynamic array creation
Jarrett Billingsley
kb3ctd2 at yahoo.com
Wed May 9 11:31:36 PDT 2007
"orgoton" <orgoton at mindless.com> wrote in message
news:f1t00h$h6i$1 at digitalmars.com...
> Assume "Foo" to be a class:
>> int[] ar = new int[10];
> If you put
> foo[] ar=new foo[10];
> will will generate an array with 10 _instances_ of foo (using default
> ctor).
You're thinking C++. D never calls constructors unless you use 'new'.
class A
{
this()
{
writefln("ctor");
}
}
void main()
{
A[] a = new A[10]; // nothing is printed
writefln(a[0]); // null
}
More information about the Digitalmars-d-learn
mailing list