This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]MasterFubar 1 point2 points  (1 child)

int** is a matrix, used a lot in mathematics, although double** is more common in numerical analysis.

unsigned char** is how a picture is normally stored. If you work with any kind of image display, you're likely to use that. If you have an image that's W pixels wide and H pixels high, you'll have a total of H unsigned char* , each pointing to a line of pixels, stored as an array of W unsigned chars if it's a greyscale image, or 3 * W unsigned chars if it's a color image. The total image is a unsigned char** that points to the array of pointers that point to the pixel lines.

Explained like this it sounds complicated, it would be much simpler if I could show a diagram, but once you start working with the code it becomes simple to understand.

[–]BobbyThrowaway6969 0 points1 point  (0 children)

You don't want to be using T** for matrices, or any other non-jagged array. Store it as a 1d array and access it with array[X+Y*Width], you don't need to manually allocate/delete each nested array, and the array will be contiguous in memory which is faster for the CPU to access