Help with multi-dimentional array

Era Scarecrow rtcvb32 at yahoo.com
Wed Jul 9 14:01:42 PDT 2008


i've tried to make a multi-dimentional array, using a struct as a container within a class. However when i try to compile it, it complains i'm not using a constant. Rather than do the long way around, is there something i'm doing wrong?

class something{
    struct xyz{
    //something
    }

    xyz[][] abc;    //declared as multi-dimentional array

    void aFunction(int left, int right)
    {
        abc = new xyz[left][right];    //error needs a const

    //work with abc afterwards
    }
    
}

I'd rather not have to do it this way, although it works.

abc.length=left;
for(int cnt; cnt < left; cnt++)
    abc[cnt].length=right;



Era


More information about the Digitalmars-d-learn mailing list