Question: I'm having trouble in compiling the following code. The compiler states:

```
Assigning to 'RawChunk::Ptr' (aka 'unsigned char (*)[128][16]') from incompatible type 'RawChunk::Chunk *' (aka 'unsigned char (*)[16][128][16]');

```

Does anyone know what I'm doing wrong? It seems like a simple mistake but I'm not sure what I'm supposed to change.

```
template <int dim>
class RawChunkWindow {
public:
    typedef unsigned char (*Ptr)[ChunkDimensions::MAX_Y][ChunkDimensions::MAX_Z];
    typedef unsigned char Chunk[ChunkDimensions::MAX_X][ChunkDimensions::MAX_Y][ChunkDimensions::MAX_Z];
    RawChunkWindow() {
        for (int i = 0; i < dim; ++i) {
            for (int j = 0; j < dim; ++j) {
                window[i][j] = &payload[i][j]; //compiler complains here
            }
        }
    }
private:
    Ptr window[dim][dim];
    Chunk payload[dim][dim];
};

```

Answer: 
Without a further explanation of what you intend on doing, I cannot be really sure, but it seems that you might have used the incorrect types for the member variables. In particular, the member variable window is of type:

window: Array of size `dim` of array of size `dim` of pointers to array of `MAX_Y` arrays of `MAX_Z` unsigned chars, that is a 2 dimensional array of pointers to 2 dimensional arrays.

payload: Array of size `dim` of array of size `dim` of array of size `MAX_X` of array of size `MAX_Y` of array of size `MAX_Z`, that is, a 5 dimensional array.
To eliminate the error the way you currently have it, you need to change the line:

window[i][j] = &payload[i][j];

to

window[i][j] = &payload[i][j][x];

for some "x" less than "ChunkDimensions::MAX\_X". It's not clear to me what you're trying to do however, and the above fix almost certainly isn't it (probably). In simple terms, it appears that you may be trying to store a collection of 3D arrays in one collection (payload), and since a 3D array is really just an array of 2D arrays, you're then trying to store a pointer to each of these 2D arrays in another collection (window). I won't even get into the use of "dim" here, since the situation is already enough to twist one's head into a knot. In any case, using a "std::vector" instead of raw c-style arrays would be much easier. For a better understanding of the issues using c-style arrays in general (in case you can't use a "std::vector" for some reason), see my previous responses to [2Dimensional Array Pointer manipulation in C++](https://stackoverflow.com/questions/9583086/2dimensional-array-pointer-manipulation-in-c/9608139#9608139) and [manipulating multidimensional arrays with functions in C++](https://stackoverflow.com/questions/9672731/manipulating-multidimensional-arrays-with-functions-in-c/9677552#9677552). You can extend the concepts I present to 3D arrays.