E
erez0001
hello,
i am trying to write a matrix class for linear algebra.
template <class T,int ROWS,int COLS> class matrix
{
private:
T m_data[COLS*ROWS];
public:
T &operator at(int x,int y) { ...}
....
};
I want to add a special function only to matrix<T,3,3>.
i still want it to inherent everything from the initial "matrix"
class.
if i just specialize it, i.e.
template <class T> matrix<T,3,3> {
public:
matrix<T,3,3> inv(void) {.....};
};
then i will only have inv(), but not everything else ( e.g. at()
function)
if on the other hand i do:
template <class T> matrix<T,3,3> : public matrix<T,3,3>
then i get a recursion ...
how do i solve that ?
i am trying to write a matrix class for linear algebra.
template <class T,int ROWS,int COLS> class matrix
{
private:
T m_data[COLS*ROWS];
public:
T &operator at(int x,int y) { ...}
....
};
I want to add a special function only to matrix<T,3,3>.
i still want it to inherent everything from the initial "matrix"
class.
if i just specialize it, i.e.
template <class T> matrix<T,3,3> {
public:
matrix<T,3,3> inv(void) {.....};
};
then i will only have inv(), but not everything else ( e.g. at()
function)
if on the other hand i do:
template <class T> matrix<T,3,3> : public matrix<T,3,3>
then i get a recursion ...
how do i solve that ?