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.
From your code snipped in the constructor of `RawChunkWindow`, it looks like your `Ptr` types should be pointers to `Chunk` types, but your `typedef` declarations don't reflect that. Instead `Ptr` is a pointer to a two-dimensional array of `char` types, not a pointer to a three-dimensional array.

So change this:

```
typedef unsigned char (*Ptr)[ChunkDimensions::MAX_Y][ChunkDimensions::MAX_Z];

```

to this:

```
typedef unsigned char (*Ptr)[ChunkDimensions::MAX_X][ChunkDimensions::MAX_Y][ChunkDimensions::MAX_Z];

```

This is also what your error code is reporting. A `unsigned char (*)[128][16]` is a pointer to a 128x16 two-dimensional array, and the compiler is complaining that you're attempting to assign a three-dimensional 16x128x16 array pointer rvalue (i.e., a `unsigned char (*)[16][128][16]` rvalue) to the wrong pointer-type.

As a side-node, be careful how you declare this object if you are planning on using them on the stack. A single `Chunk` type instance will take up 32Kb if the dimensions are 16x128x16, and a two-dimensional array of those could quickly eat up your stack-space if you pass too large a value as the template argument for `dim`.