So I have a header file, which looks like this:
class Crc16
{
public:
Crc16();
static long calculateCrc(const BYTE* ptr, long length);
long getCrc();
private:
long m_crc;
};
where BYTE is an unsigned char. This implementation takes the data and returns the CRC for that particulate data. The polynomial used is a fixed one, i.e. hard coded within the static function. However, I would like to extend this implementation by letting someone define his own polynomial and carrying out the calculation. I have thought of creating a new constructor which takes the new polynomial and assigns it to a member, but it will be not possible to use it in the static function. Another possibility is to create a new function which is not static, which will take a polynommial as an argument. But the code in the static and non-static version will almost be identical. I do not want change the interface of the static function I have, since it is used in many places. What would the best solution be, from an architechural point of view?