tomstewart89 / BasicLinearAlgebra

A library for using matrices and linear algebra on Arduino
MIT License
187 stars 38 forks source link

What data type to return in function? #12

Closed shen-cs closed 7 years ago

shen-cs commented 7 years ago

Hello,

I'm writing a class with Matrix class as constructor parameters. Some of functions of this class also return Matrix. I tried Matrix<int, int> and Matrix<int, int, class, class> as data type to return in my function but both of them didn't work.

Here's the error message: error: type/value mismatch at argument 1 in template parameter list for 'template<int rows, int cols, class ElemT, class MemT> class Matrix' Matrix<int, int, class, class> _R;

tomstewart89 commented 7 years ago

So there's two options; you can either fix the size of the matrix and declare it as Matrix<3,3> _R; for example. Or you can make your class a template class as well and pass the size in as a template parameter. You can read up on template classes here: http://www.cplusplus.com/doc/oldtutorial/templates/