Compiler Error C2536
Collapse the table of content
Expand the table of content
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here. ArchiveDisclaimer

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() {}
© 2015 Microsoft