It's been a long time since I worked with C++, but I have a class that uses 3-dimensional data and I can't figure out how I can make this work. I need the sizes of the dimensions to be defined in the constructor. I tried this in the header:
class CImage
{
public:
float values[][][];
...
}
and this in the constructor:
CImage::CImage(int cols, int rows, int depth)
{
values[cols][rows][depth];
}
but this returns the error: "declaration of `values' as multidimensional array must have bounds for all dimensions except the first".
Also using this in the constructor does not work:
values = new float[cols][rows][depth];
I also tried using vector, but without much success. Header:
vector<vector<vector<float> > > values;
Nothing in constructor. No compiler errors, but when I try to set a value:
values[c][r][d] = value;
the program crashes.
It seems so basic, but I just can't figure it out...