Example code for a 2-Dimentional Array in C++

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

   a_ptr=new int*[dim1]; //creates a new array of ptrs to int 
   for(int i=0; i < dim1; ++i)
   }
     a_ptr[i]=new int[dim2];
   }
   // access the members like you can with normal 2d arrays
   //a_ptr[2][4]
   
Last Modified 12:23 PM 10/20/2010

ACM Code of Ethics

Exteme Programming