 <p>First, you never want to do default initializations in calling code, you can create a constructor for your struct and do it there:</p> <pre><code>struct Neuron { Neuron() : activation(0.0), bias(0.0), incomingWeights(0) {} double activation; double bias; double *incomingWeights; }; </code></pre> <p>Then (since this is C++)</p> <pre><code>for (int i = 0; i &lt; din; i++) { ann.inputLayer[i] = new Neuron[din]; </code></pre> <p>You should use <code>new</code> over <code>malloc</code> in C++, though if you ever did need <code>malloc</code> your statement would need to be fixed, to:</p> <pre><code>ann.inputLayer = (Neuron*)malloc(din * sizeof(Neuron)); </code></pre>