if 4 lems are created in a 2 by 2 array, why does the for statement beneath the while statement output index 2 and 3 as being NULL?
Could it be the fact that I flattened the array by accessing it sequentially without the row/column notation? I thought that a multidimensional array was stored in memory sequentially anyways, so the way I am doing it should be fine....
Code:
for (int r=0; r <= rows; r++)
{
for (int c=0; c <= cols; c++)
{
lems[r][c] = new Lem(r, c, (r*c)+c); // this statement is executed 4 times
cin >> lems[r][c]->agenda;
cout << lems[r][c]->agenda << endl;
}
}
Lem** plems = (Lem**)lems;
for(int i = 0; i < size; i++)
{
if ( plems[i] == 0 )
cout << "huh?" << i << endl; // 2 and 3 are NULL?
}