How to get and address of newly created object and put it in pointer array?

int maxNeurons = 100;
Neuron*[] neurons = new Neuron*[](maxNeurons);

Neuron n;

for(int i = 0; i < maxNeurons; i++)
{
        n = new Neuron();
        neurons[] = &n; // here &n always returns same adress
}

writefln("Thread func complete. Len: %s", neurons);


This script above will print array with all the same address values, why is that?


Thanks

Reply via email to