Introduction to OOP | Chapter 21: Software Frameworks : | next | previous | audio | real | text |
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!