If I have three arrays (array01, array02, array03), and an integer variable will determine which array I need to work with, I can just use an "if / else if / else" set of statements to handle that.
But if I have 20 arrays, this becomes unwieldy.
So, what's the best way to set things up so that I can easily handle working with the correct array? (Obviously, the method would have to allow me to specify an index for the array in question, so I can work with the elements of it.) Would it be an array of pointers? How would I set this up?
------------------------------
Example based on the ugly method:
// These are determined elsewhere
int aNum = xxx;
int i = yyy;
if (aNum == 1)
{
output << array01[i];
}
elseif (aNum == 2)
{
output << array02[i];
}
else
{
output << array03[i];
}


Sign In
Create Account

Back to top









