1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
|
#define TEMPLATEMATRIX template<class T, int C, int R>
#define TEMPLATEMATRIXT template<class T, int C, int R, int R1>
#include <iostream>
#include <sstream>
using namespace std;
TEMPLATEMATRIX class Matrix;
//Multiplication
TEMPLATEMATRIXT Matrix<T, R1, R> operator* (Matrix<T, R1, C> a, Matrix<T, C, R> b);
TEMPLATEMATRIX Matrix<T, C, R> operator* (Matrix<T, C, R> a, Matrix<T, C, R> b);
...
TEMPLATEMATRIX class Matrix{
private:
T matrixData[C][R];
int rows, columns;
public:
Matrix(){
this->rows=R;
this->columns=C;
for(int x=0;x<C;x++)
for(int y=0;y<R;y++)
this->matrixData[x][y]=0;
}
T& operator()(int, int);
//Multiplication
template<class T, int C, int R, int R1> friend Matrix<T, R1, R> operator* (Matrix<T, R1, C> a, Matrix<T, C, R> b);
friend Matrix<T, C, R> operator* <>(Matrix<T, C, R> a, Matrix<T, C, R> b);
friend Matrix<T, C, R> operator* <>(Matrix<T, C, R> a, T b);
....
|