I've trying to implement polynomials of arbitrary order as a C++ template,

as shown here:

template <unsigned long int N>

class Polynomial

{

public:

Polynomial ();

~Polynomial ();

float getCoefficient (unsigned long int

const index);

void setCoefficient (unsigned long int const

index, float const value);

float evaluate (float const x);

Polynomial <N-1> derive ();

Polynomial <N+1> integrate ();

private:

float mCoefficients[N+1];

};

As could be expected, I've found problems with the extreme order

polynomials, that is, trying to derive a polynomial of 0 order (in fact, a

real number) or trying to integrate a polynomial of maximum order ((2^N) -

1).

So the question is, how can I deal with extreme order polynomials? It's

possible to provide different declarations (not only definitions) to

derive() and integrate()? Should I detect those illegal attempts and break

it with exception throwing?

Thank you