C2203: Too many initializers for Ctor arguments

[ERROR]

Description

An initialization of an array of class objects with constructor call arguments was having more arguments than elements in the array.

Example
  struct A {

  
    A(int);

  
  };

  
  void main() {

  
    A a[3]={3,4,5,6};  // errors

  
    A a[3]={3,4,5};  // ok

  
  }

  
Tips

Provide the same number of arguments than number of elements in the array of class objects. If you want to make calls to constructors with more than one argument, use explicit calls of constructors.

  struct A {

  
    A(int);

  
    A();

  
    A(int,int);

  
  };

  
  void main() {

  
    A a[3]={A(3,4),5,A()};

  
      // first element calls A::A(int,int)

  
      // second element calls A::A(int)

  
      // third element calls A::A()

  
  }

  

See also