I have just run into ridiculous problems with arrays, and it appears I have no idea how they work, so I need some help.
I have this class:
class pixelmap{
public:
pixelmap(const uint& width, const uint& height);
pixelmap();
~pixelmap();
uint width;
uint height;
uint *values;
pixel *pixels;
void setValues();
void set(const uint& width, const uint& height);
private:
};
I'm trying to use the pixels pointer to put a multidimensional array on the heap, like in the constructor:
pixelmap::pixelmap(const uint& width, const uint& height){
this->width = width;
this->height = height;
this->values = new uint[width][height];
this->pixels = new pixel[width][height];
}
First of all, am I initializing this right? And, how do I access each r, g, and b in the pixels array? Ive tried many different ways, and I just keep getting errors:
p.pixels[x, y].r; //I get a warning about the left hand of the operand not having an effect
p.pixels[x][y].r; //no match for operator[] error
Also, can I just delete[] it, or do I have to delete[] it for every row? I'm at a loss here, and pretty frustrated.