In terms of memory layout, a matrix is one long array with no padding between each element. It's effectively equivalent to this:
1 2 3 4 5
// ...is actually this:
Knowing this, we can easily compute the destination: Array + (Column-Index + Row-Index). I'm not 100% sure about why this is, but I've thought of a few possible reasons:
1. Book-keeping is easier and less stack space is required to keep track of each row.
2. Avoids memory fragmentation (if dynamically allocated).
3. Makes more effective use of the CPU & code caches.
4. Easier to optimise.
Let's say you have a 3x3 matrix on a piece of paper. If you search for the location 1,4, it is not possible because it is off the matrix. You can't do it on the because it doesn't work like that in C++. When I check to see if that location is NULL, it isn't. That is what I meant by out of bound.
That's impossible. An address is NULL only when it's 0. Since arrays are pointers to the first element of a sequence, the first element may be at address 0 (and crash the program with a segmentation fault if you try to write to it), but an element even one place away from the first can't have address 0
Though I don't think you can actually create an array starting at NULL