Compiler Error C2536

'class::identifier' : cannot specify explicit initializer for arrays

A member of a class, structure, or union could not be initialized. Possible causes:

  1. A constructor is not available to initialize one or more members of an array. If the size of the array is greater than the number of initializers, a default constructor must be defined.

  2. A nonstatic array declared with the const specifier. This kind of array cannot be explicitly initialized.

The following sample generates C2536:

// C2536.cpp
// compile with: /c
class C {
   int i;
   int j;
   int k;
};

class D {
   C aC[5];
   D() : aC(1,2,3,4,5) {}   // C2536
   // try the following line instead
   // D() {}
};