Re: A89: Matrix Errors


[Prev][Next][Index][Thread]

Re: A89: Matrix Errors



Arrays of dynamic size need to be dynamically allocated.  The format you're
accustomed to using only works when it's hard-coded constant sizes.  Do
something like this instead:

int lvl=1;
int **hp = new int[lvl][2];



In a message dated 2/11/2001 3:01:34 PM Eastern Standard Time,
CalenWakefield@aol.com writes:


I am having trouble using matrices.  If I declare a matrix and then try to
reference it the compiler gives me an error "Initializer value is not a
constant."  Heres the code:

int stats[6][8]=
{{1,20,0,5,3,4,6,0},
{2,25,5,8,5,5,7,50},
{3,29,7,10,8,7,9,150},
{4,32,11,14,10,10,10,300},
{5,37,14,15,14,11,13,500},
{6,40,15,20,17,15,15,750},};
int lvl=1;
int hp=stats[lvl][2],mhp=stats[lvl][2],mp=stats[lvl][3],mmp=stats[lvl][3];
                       /\
                       | |
the error points to here

and one more thing, this code is outside of all of my functions so it is
global, if that matters.  Can someone help me please?





----
Jonah Cohen
<ComAsYuAre@aol.com>
http://jonah.ticalc.org

Follow-Ups: