| description | | hints | | solution | | discussion |
| list of all exercises | |||
As we have seen in the "Template" lecture, a template parameter can also be useful to implement items with a base type of different precision. As an example, change the class Rational into a template Rational<T> where by choosing different T (e.g., short, int, long, long long) one can specify the memory usage and range of numbers which can be represented. You find the source for the Rational class in the files Rational.h (*) and Rational.cpp (*).
Then use Rational<long long> to compute the harmonic numbers and Bernulli numbers up to 32 (see numbers.cpp (*)).