I was able to find some help on allocating 2-d array.  However, the example 
allocated a 2d array of ints.  For someone who is not familiar with C/C++ 
pointers I can't tell the difference between the pointers, pointers to array of 
itegers, and the integer items.

Here is the code I found.

int **array_ptr; //two * are needed because it is a pointer to a pointer

array_ptr=new int*[firstnumber]; //new array of pointers to int objects
for(int i=0; i<firstnumber; ++i)
array_ptr[i]=new int[secondnumber];

I was able to change this so it compiled but I get runtime error when I try to 
deallocate it.  I'm missing an important point somewhere.

I could use an example of a 2-d array that holds a complex type so the pointers 
and the items are totally different.  

Could someone provide an example of, say, a 2-d array of PERSON objects, 
including the deallocation of the array?

Thanks,

Jimmy J. Johnson



Reply via email to