This program should help clarify to you the use of
template
s and function
objects.
Modify either your template'd sort from class or the one associated with the template'd Set to accept a function argument which it should use to compare the elements of the array. This function should return true when the items passed are 'out of order' (left to right) in the argument list. (i.e. For an ascending sort, the function would return the result of a > operation. For a descending sort, the function would return the result of a < operation. A class with complicated data might require comparing several data members in order to come up with a determination of 'out of order'.) All other aspects of the sort are as before.
Show your sort's power by sorting arrays of
short
integers
double
s
char
aracters
String
class
objects
all in one test application. (Hint: It might prove advantageous to overload your templated swap for Cstrings ...of a particular length.)
Also pass comparison function (object)s which result in both ascending and descending order of each of the arrays' elements.
This assignment is (Level 2).