Matrix<T, n, m>
and Matrix<T, m, n>
are different classes at all when m != n
. It means you couldn't access the private member of Matrix<T, n, m>
in the member function of Matrix<T, m, n>
.Matrix<T, m, n>
and Matrix<T, n, m>
are different classes when m
and n
are not the same. One cannot access the private
members of the other. You can avoid the access problems by providing public
member functions that provide access to the private
member variables.m
and n
are the same.m
. In this Matrix elements is a private variable and hence you can not access it. I would suggest either creating a public getter function to return a pointer to elements or making elements a public variable (but that may not be good style as it doesn't encapsulate the data).