CPSC 1720 - Homework #14

Write a C++ class that has an array of integers as a member variable, a pure virtual member function

     bool compare(int x, int y) = 0;

that compares its two parameters and returns a boolean value, and the member function

     void sort()

that uses the comparison defined by the compare virtual function to sort the array. The sort function will swap a pair of array elements a[k] and a[j] if

     compare(a[k], a[j])

returns true. Use this class to produce two other classes using inheritance. One of these two classes should sort its array in ascending order and the other should sort its array in descending order using the inherited sort function.

150 East College Avenue * Ephraim, Utah 84627 * Email: ude.wons@nosneros.htrag
© 2004 Snow College * All Rights Reserved
©