Here's the scenario:
In a class, I have a two dimensional array, let's call it: 2DArray.
To declare it, I use:
int 2DArray[20][20];
Now, naturally, it is an array of integers, holding 441 (21 x 21) values.
But, this "20" I use is pretty open to change. Sometimes I might feel like throwing in a 50, sometimes a 2, it depends on my current mood. Now, the problem is, I use this number "20" many many times throughout my class AND main program, so, going through each time and changing the "20"s that apply can get rather tiresome.
What I was hoping was to find a way that I could make a variable within my class, to hold the dimensions of my 2DArray (it will always be symmetrical, I.e. 1x1 or 5x5 or 50x50), and then declare a 2D Array based on that variable? That way I'll also be able to retrieve the value from my main app and use the number there if calculations are needed.
Thanks
Erik



LinkBack URL
About LinkBacks



