Another simple solution is to just use a 1D array:
Qt Code:
int* array = new int[rows * columns];To copy to clipboard, switch view to plain text mode
and do the 2D indexing yourself, which is very simple.
This approach guarantees that your allocated storage occupies a single, contiguous chunk of memory, something that may be good, bad or indifferent depending on exactly what you're doing. It is probably slightly faster than performing the multiple, small allocations required by the 2D case.
Bookmarks