My code so far:
class Grid {
private:
float data[100][100][100];
public:
Grid(float data_in[100][100][100]);
~Grid();
void drawDebug();
void draw();
};
Grid::Grid(float data_in[100][100][100]){
data = data_in; // %26lt;---Here lies the problem
};
Grid::~Grid(){};
void Grid::drawDebug(){};
void Grid::draw(){};
The problem shows up in the area marked with the comment. The compiler is treating the input parameter, data_in, as a type "float[][100][100]". I have no idea why it's dropping the size of the first dimension, but obviously it is unable to assign data_in to data because data is still a float[100][100][100].
Help greatly appreciated.
How do you pass 3D arrays through a constructor in C++?
What you should do is declare data as:
float ***data;
then the constructor:
Grid::Grid(float ***data_in) {
data = data_in;
Then, somewhere, you should hold the size of the array. Probably a variable sent to your constructor.
Reply:I'm a little rusty in C++, but try the following.
data = %26amp;data_in;
flower pictures
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment