Help with multi-dimentional array
    Era Scarecrow 
    rtcvb32 at yahoo.com
       
    Wed Jul  9 15:26:10 PDT 2008
    
    
  
Koroskin Denis Wrote:
> No, you create *an array*, not objects of concrete type. Thus, no  
> constructor is called and an array contains a butch of uninitialized class  
> references. And since no ctor is called, you can't pass any ctor  
> parameters right there.
> 
> So you still need a loop to initialize the array properly.
 I see. so after i do the = new xyz[][](left,right), and i wanted to fill in x,y,z i'd have to
// this(x,y,z){} //still this constructor
z=100;
for(int x=0; x<left; x++)
    for (int y=0; y<right; y++)
        xyz[x][y] = new xyz(x,y,z)
 Well, even if we have to do this, creating the basic array is a lot simpler.
 Now let me doublecheck once more. If i DID this.
 abc = new xyz[][](4,4);    //Non-stack and GC handles it, or i can malloc
 abcd [4][4]xyz;    //(Stack / non-Stack) static allocation
 I'll assume that
 1) abcd is an array of 4 pointers that have 4 pointers each
 2) It is not created by the GC, but instead resides on the Stack? (Please confirm)
 If this doesn't make it on the stack, i'll need to know a way that i can, in case i need to make a small array that i don't want to burden the garbage collector. (or worse yet, if i make a module that goes into a kernel that doesn't support GC, i don't want to worry about freeing the memory). Although if i recall it's probably an import. (std.mem.alloca?)
 Era
    
    
More information about the Digitalmars-d-learn
mailing list