title: C++ using new to create object array with initializer
body: <p>I wrote a class, something like this (just for demonstration) :</p>
  
  <pre><code>class cls{
  public:
      cls(int a):value(a){}
  private:
      int value;
  };
  </code></pre>
  
  <p>And I want to dynamically create an array, each element initialized to a specific value like 2:</p>
  
  <pre><code>cls *arr = new cls[N](2);
  </code></pre>
  
  <p>But g++ reported 'error: parenthesized initializer in array new'.</p>
  
  <p>I searched the Internet, but only to find similar questions about basic types like <code>int</code>  and <code>double</code>, and answer is NO WAY. </p>
  
  <p>Suppose the class must be initialized, how to solve the problem? Do I have to abandon constructer?</p>