I am trying to create a matrix template class. I would like Sum() function to act differently for bool types. What I need to make it elegant class is partial template specialization. How do I do it?
template <class DATA,class INT_TYPE>
class TMatrix
{
private:
DATA *d;
INT_TYPE rows,cols;
public:
DATA Sum(); //count the sum of element
// for bool data type I would like to get:
INT_TYPE Sum(); //counts the number of elements that are true, so it cannot return bool, but INT_TYPE instead
}
And how do I create definition of such function outside the class?
Thanks in advance,
Regards,
Misery