Closed davidbsp closed 6 years ago
Hi @davidbsp ,
Because Matrix is a template class, Matrix<2,1>
and Matrix<2,2>
(for example) are treated as distinct datatypes in C++. void function (BLA::Matrix P)
expects just a single type so it's not possible to pass matrices of arbitrary size a non-template function. On the other hand, you can define a template function like so: template <int rows, int cols> void function(BLA::Matrix<rows,cols> P)
which will more or less do what you're looking for. If you haven't come across them already, you can read up on template functions here: http://www.cplusplus.com/doc/oldtutorial/templates/
Hi again @tomstewart89! I solved it using a template function just like you suggested. Many Thanks!
No problem!
Hi @tomstewart89,
Is it not possible to pass a matrix as parameter of a function without specifying the number of rows and columns?
I would like to have a function something like this: void function (BLA::Matrix P), and inside the function I would use GetColCount() and GetRowCount() to handle matrixes of any size.
Thanks!