M
MathStuf
I have a matrix class and I would like to add a method that is only
applicable when the template type is a of another class. How can I
specialize the class to allow for the new method and hide it with any
other type?
template<class T> class Matrix
{
public:
Matrix();
Matrix(Ini
&ini); // Only
applicable with MyClass
Matrix(unsigned w, unsigned h, T &d = T());
void ImportIni(Ini
&ini); // Only applicable
with MyClass
void ExportIni(std:fstream &fout, const String &val);// Only
applicable with MyClass
void AddRow(T &d = T());
void AddCol(T &d = T());
bool InsertRow(unsigned pos, T &d = T());
bool InsertCol(unsigned pos, T &d = T());
bool DeleteRow(unsigned pos);
bool DeleteCol(unsigned pos);
bool Set(unsigned row, unsigned col, T &s);
T Get(unsigned row, unsigned col);
std::vector<T> GetRow(unsigned row);
std::vector<T> GetCol(unsigned col);
unsigned GetHeight();
unsigned GetWidth();
T operator[](Point &p);
std::vector<T> operator[](int col);
private:
std::vector< std::vector<T> > matrix;
unsigned height;
unsigned width;
};
applicable when the template type is a of another class. How can I
specialize the class to allow for the new method and hide it with any
other type?
template<class T> class Matrix
{
public:
Matrix();
Matrix(Ini
&ini); // Only
applicable with MyClass
Matrix(unsigned w, unsigned h, T &d = T());
void ImportIni(Ini
&ini); // Only applicable
with MyClass
void ExportIni(std:fstream &fout, const String &val);// Only
applicable with MyClass
void AddRow(T &d = T());
void AddCol(T &d = T());
bool InsertRow(unsigned pos, T &d = T());
bool InsertCol(unsigned pos, T &d = T());
bool DeleteRow(unsigned pos);
bool DeleteCol(unsigned pos);
bool Set(unsigned row, unsigned col, T &s);
T Get(unsigned row, unsigned col);
std::vector<T> GetRow(unsigned row);
std::vector<T> GetCol(unsigned col);
unsigned GetHeight();
unsigned GetWidth();
T operator[](Point &p);
std::vector<T> operator[](int col);
private:
std::vector< std::vector<T> > matrix;
unsigned height;
unsigned width;
};