Arrays and constructors

It seems like itsn’t possible for me to create an array of objects with a constructor or containing an object with a constructor, is that correct or is it a bug?

Same problem I had! There are some workarounds I found:

  1. YourClass a[3]={YourClass(), YourClass(), YourClass()};

    //YourClass a[3]={YourClass()}; ====>won’t work!

  2. const int size=sizeof(YourClass);

    char ptr[3*size];

    YourClass *a=(YourClass *)ptr;

    for(int i=0;i<3;i++)a[i]=YourClass();

Hope this helps.