Xavier
Xavier

Reputation: 9049

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?

Upvotes: 2

Views: 155

Answers (2)

Stvad
Stvad

Reputation: 380

T*** getDataPointer() {return data;} maybe you need something like this?

Upvotes: -1

Mr.Anubis
Mr.Anubis

Reputation: 5322

Change the signature to :

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

Upvotes: 8

Related Questions