How do you dynamically allocate a 2D matrix in C++? I have tried based on what I already know:
#include int main(){ int rows; int c
or you can just allocate a 1D array but reference elements in a 2D fashion:
to address row 2, column 3 (top left corner is row 0, column 0):
arr[2 * MATRIX_WIDTH + 3]
where MATRIX_WIDTH is the number of elements in a row.