RSS
Follow Us
Contribute
 
 
 
 

Error C2073: (identifier) : elements of partially initialized array must have a default constructor

 
We need YOUR SKILLS in this collaborative work, to build the largest solution center for error messages.

From $1

Table of contents
  1. 1. Cause
  2. 2. Solution
  3. 3. About This Article

Cause

Too few initializers were specified for an array of user-defined types or constants.

class A {
public:
   A( int );   // constructor for ints only
};
A a[3] = { A(1), A(2) };   // C2073, no default constructor

Solution

If an explicit initializer and its corresponding constructor are not specified for an array member, a default constructor must be supplied.

class A {
public:
   A();
   A( int );
};
A a[3] = { A(1), A(2) };

About This Article

This article is a derivative work based on Compiler Error C2073 which is provided by MSDN Community Content - Visual C++.

 
 
 
 
Comments