Passing parameter when creating object array

Jarrett Billingsley kb3ctd2 at yahoo.com
Mon Aug 6 19:15:45 PDT 2007


"Daniel White" <twinbee41 at skytopia.com> wrote in message 
news:f98h52$7bj$1 at digitalmars.com...
> I've just found out from elsewhere that it's not possible in C++ to create 
> an array of objects whilst simultaneously passing a parameter to the 
> constructor of each of those objects. Something like this returns an 
> error:
>
> Myclass x (10)[50]
>
> I don't want to have to do:
>
> Myclass x[5] = {10,10,10,10,10,10.................}  // ...and so on
>
> Does D support the more intuitive Myclass x (10)[50] mechanism?

D doesn't support instantiating an array of instances of classes in one 
statement in any way, so.. no. 




More information about the Digitalmars-d-learn mailing list