title: Dynamic array initialization
body: <p>I want to make a dynamic array of foo, with the number of items being x. Arguments y and z are to be passed to the constructor of the item foo. I was hoping to do something similar to:</p>
  
  <pre><code>Foo* bar = new Foo(y, z)[x];
  </code></pre>
  
  <p>However that produced the following compiler error:</p>
  
  <pre><code> error: expected `;' before '[' token
  </code></pre>
  
  <p>So after speaking with an experienced friend, he gave me this, which he admitted was a lazy way of doing it, but it works. I was wondering, is there a better/proper way?</p>
  
  <pre><code>Foo* bar = (Foo*) new int[x];
  for (int i = 0; i &lt; x; i++) {
      bar[i] = Foo(y, z);
  }
  </code></pre>