While writing the following function abs
, I get the error:
non-member function unsigned int abs(const T&)
cannot have cv-qualifier.
template<typename T>
inline unsigned int abs(const T& t) const
{
return t>0?t:-t;
}
After removing the const
qualifier for the function there is no error. Since I am not modifying t
inside the function the above code should have compiled. I am wondering why I got the error?