简体   繁体   中英

How do I return a pointer to a multidimensional array?

I have a template class in C++ that looks like this:

template <typename T, int xMax, int yMax, int zMax>
class Volume {
public:
    T*[64][64] getDataPointer() {return data;} //compiler doesn't like this line
private:
    T data[xMax][yMax][zMax];
};

typedef Volume<unsigned char, 64, 64, 64> Chunk;

The compiler doesn't like the return I have for getDataPointer(). I want to return the same type I would then use to pass to this function:

void perlin2D(unsigned char (*chunk)[64][64])

Can someone show me how to do that?

将签名更改为:

T (*getDataPointer())[64][64] {return data;}

T *** getDataPointer(){返回数据;}也许您需要这样的东西?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM