Assignment #6: C++ Templates, Function Objects, Inheritance
- Implement a function template that takes a vector and a function
object representing the less than function as parameters, and sorts
the vector.
You can use any simple quadratic sort.
- Implement a function template that takes a vector
as parameter and sorts it, using the normal default for comparisons.
You should invoke your two-parameter sort, above.
- Write a Circle class that contains a reasonable implementation of
operator<, and then write a test program that creates, populates,
and then sorts a vector of Circle objects.
- Write a Rectangle class. Since there is no reasonable
implementation of operator<, write a test program that
creates, populates, and then sorts by area a vector of
Rectangle objects. You'll need to write a function object class
to provide the comparator.
- Write a test program that will sort a vector that contains
some Circles and some Rectangles (using area to order).
First, this implies that you must create an abstract Shape class
(that is extended by Circle and Rectangle.
Second, you must store pointers to Shapes in the vector.
Third, you must provide a function object class to compare two
Shape * objects.