Lefsler
Lefsler

Reputation: 1768

Template Matrix with Column number equal

I'm have a homework that tell us to create a template for a matrix where the column number of the matrix1 is equal to the row number of the column 2

I tried that:

 #define TEMPLATEMATRIXCR template<class T, int , int > 
 TEMPLATEMATRIXCR Matrix<T, R> operator* (Matrix<T, int, R> a, Matrix<T, R, int> b);

It dont work, for example

Matrix [10][30]
Matrix [20][10]
So I need the matrix with [20][30]; //sorry if my logic is messed. It tells me that the E is not defined.

In the first moment I did

TEMPLATEMATRIX Matrix<T, C, R> operator* (Matrix<T, C, R> a, Matrix<T,R, C> b);

But it's not what he wants, so now I can't just fix 2 numbers and make the others "free"

How can I do that using templates?

Upvotes: 0

Views: 73

Answers (1)

WhozCraig
WhozCraig

Reputation: 66224

I'm likely not quite getting what you're asking, but isn't this ultimately what you're trying to do?

template<typename T, size_t R1, size_t C1, size_t R2>
Matrix<T, R2, C1> operator *(const Matrix<T, R1, C1>&, const Matrix<T, R2, R1>&);

Or are you trying to just make C1 and R2 programatically arbitrary?

Upvotes: 1

Related Questions