   2d Array of objects
  So I''m just trying to do:Object* arr_obj = new Object[10][10];and I get a "cannot convert error"...How do I do a 2d array...and does the default constructor of Object get called for each one in the array? 
Object** arr_obj;arr_obj = new Object[10];for(int i = 0; i < 10; i++){  arr_obj[i] = new Object[10];};quote:Original post by maxplus305  and does the default constructor of Object get called for each one in the array?   Yes ;  There are a few different ways to do this.1)I believe this is the most common:   Object** arr_obj = new Object*[x_size];for (i = 0; i < x_size; ++i)  p[i] = new Object[y_size];//Access (3, 4)arr_obj[3][4].DoSomething();//Cleanupfor (i = 0; i < x_size; ++i)  delete [] arr_obj[i];delete [] arr_obj;2)    This is one you'll see often as well:   Object* arr_obj;arr_obj = new Object[x_size * y_size];//Access (3, 4)arr_obj[3 + 4 * x_size].DoSomething();//Cleanupdelete [] arr_obj;3)    This way is better for memory performance, and involves only two new  s.  (I learned of it just recently from a post by Null and Void):   Object* arr_obj_real = new Object[x_size * y_size];Object** arr_obj = new Object*[x_size];for (i = 0; i < x_size; ++i)  p[i] = arr_obj_real[i * y_size];//Access (3, 4)arr_obj[3][4].DoSomething();//Cleanupdelete [] arr_obj_real;delete [] arr_obj;The first will have multiple peices of memory, which may not be close to each other, potentially causing cache misses, and thus performance loss.  The second always has only one single chunk of memory, but you have to manage the math yourself, which clutters code a bit, and could lead to bugs.  The third pretty much has the advantages of both, except that it looks a little funny.  But there will never be more than two chunks of memory, one of which will be quite small, and you still let the compiler take care of the array indexing math.   [edited by - Agony on February 10, 2004 3:43:40 PM] [edited by - Agony on February 10, 2004 3:44:52 PM]