I have a portion of code that goes like this (assume all types are int
):
for(int i = 0; i < h; ++i)
{
for(int i = 0; i < h; ++i)
{
if(...)
{
a = B[i][j]
}
else
{
a = C[i][j]
}
}
}
I would like to write it so that I only check the if
condition once. But how would I go in declaring the pointer to the 2D array adequately (variable D in the example below) ?
if(...)
{
D = B;
}
else
{
D = C;
}
for(int i = 0; i < h; ++i)
{
for(int i = 0; i < h; ++i)
{
a = D[i][j]
}
}