I want to first initialize "dummy" array when i create a object. I have this in private part of my class.
// Initialize dummy array when object is initialized.
int* matrix_[0][0];
Then i want later to initialize new array to replace the dummy one (one that has actual size). I have method for this in my class:
void set_map_size(int width, int height) {
int* pm[width][height];
matrix_ = pm;
}
So the problem is when I try to initialize this array after the creation of the object. I want other methods / other objects to have access to this array.
Maybe I should have pointer? Initialize pointer as nullptr when object is created and then change pointer to point to array?
int* matrix_[0][0];doesn't look right, is this standard? Shouldn't you usemallocornewinstead of a local automatic variable in that function? To avoid all these, consider usingstd::vectorif you canint* matrix_[0][0]isn't right, it declares a 0 length 2d array of pointers. But malloc should pretty much never be used in c++, and raw new only very rarely has a place.