我在编译以下代码时遇到了麻烦。编译器声明:
Assigning to 'RawChunk::Ptr' (aka 'unsigned char (*)[128][16]') from incompatible type 'RawChunk::Chunk *' (aka 'unsigned char (*)[16][128][16]');
有谁知道我做错了什么?这似乎是一个简单的错误,但我不确定我应该改变什么。
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];
};