Get object address when creating it in for loop

Caslav Sabani via Digitalmars-d digitalmars-d at puremagic.com
Mon May 5 10:02:24 PDT 2014


Hi Guys,


Thanks so much for your reply. This fixes my problem like Adam D.
Ruppe suggested:

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

Neuron n;

for(int i = 0; i < maxNeurons; i++)
{
	n = new Neuron();
	neurons[] = n;
}

But can you give me a more details so I can understand what is
going on. What is the difference between

Neuron[] neurons = new Neuron[](maxNeurons);

and

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


As I understand Neuron*[] should create array which elements are
pointers?


Is it possible to instantiate 100 objects in a for loop and get a
address of each object instance and store it in array of pointers?



Thanks


More information about the Digitalmars-d mailing list