
Row Major Order: In this format, the matrix is stored in row order, with each row stored before the next row in memory. I.e. row N comes before row N+1.
Column Major Order: In this format, the matrix is stored in column-order, with each column stored before the next column in memory. I.e. column N comes before column N+1.

You can see the differences graphically below.



C++ stores multi-dimensional data in row-major format.

Efficiently accessing elements of a 2d matrix
Similar to the storage format, there are 2 ways to access data in a 2d matrix.

Loop Over Rows first: All elements of a row are processed before any element of the next row.
Loop Over Columns first: All elements of a column are processed before any element of the next column.
