Instead of dealing with 2D arrays, I suggest you declare a simple Matrix class:

C++

class Matrix { public: //number of rows of this matrix int Rows() const { return m_rows; } //number of columns of this matrix int Columns() const { return m_columns; } //direct access to the internal data: use with caution!! double* Data() { return m_data; } //constructs an empty matrix Matrix() { m_data = NULL; m_rows = 0; m_columns = 0; } //copy-constructor Matrix(const Matrix& mat) { //clones the matrix if it is not empty if (mat.Rows() != 0 && mat.Columns() != 0) { Alloc(mat.Rows(), mat.Columns()); memcpy(m_data, mat.Data(), m_rows * m_columns * sizeof(double)); } } //cleans this matrix ~Matrix() { Free(); } //allocates memory for this matrix void Alloc(int rows, int columns) { Free(); m_data = new[rows * columns]; m_rows = rows; m_columns = columns; } //frees the memory void Free() { if (m_data != NULL) delete [] m_data; m_data = NULL; m_rows = 0; m_columns = 0; } //reads the k-th element double operator[](int k) const { return m_data[k]; } //writes the k-th element double& operator[](int k) { return m_values[k]; } //reads the element at line i and column j double operator()(int i, int j) const { return m_data[i * m_columns + j]; } //writes the element at line i and column j double& operator()(int i, int j) { return m_data[i * m_columns + j]; } private: int m_rows, m_columns; double* m_data; };

Then, don't forget to pass it by reference (or pointers) to any function, otherwise the copy-constructor will slow down the whole process. Or you can just remove the copy-constructor implementation (but also the destructor to avoid deleting the same pointer twice!)

-----------------

You can also use templates:

C++

template<int SIZE> void func(double (*rot)[SIZE]) { }

But I still think the Matrix class is a better solution.