To apply the framework to a new problem, we subclass and override the
deferred methods:
class EmployeeSorter : public InsertionSorter {
public:
EmployeeSorter (Employee * d[], int n)
{ data = d; sze = n; }
private:
Employee * data[];
int sze = n;
virtual int size () { return sze; }
virtual bool lessThan (int i, int j)
{ return data[i]->startingYear < data[j]->startingYear; }
virtual void swap (int i, int j) {
Employee * temp = v[i];
v[i] = v[j];
v[j] = temp;
}
}
We can now reuse the high level algorithm without making any change
to the original source code!