IComparable
and ISerializable
are abstract interface classes, Person
is derived from them both (multiple interface inheritance).
Implement the missing functions in Person.h
and Person.cpp
. You may need to declare new functions as well.
Decomposition of the program:
- IComparable.h, ISerializable.h, Person.h: class declaration headers;
- Person.cpp: implementation of class members declared in the header;
- Main.cpp: the main program with testing code.
Sorter.h
declares a Sorter
class that is a collection of multiple sorting algorithms. Each sorting algorithm takes an array of IComparable*
pointers. These functions can sort any type that implements the IComparable
interface such as our Person
type.
Add a Sorter.cpp
file and implement bubble sort and quicksort there. Test your solution in Main.cpp
.
There are many other sorting alorigthms. Add another one and test it in the main function. Examples: merge sort (in place or not), insertion sort.
Add another sortable type. Implementing the IComparable
interface makes a type sortable. Create an array of your type and sort it via the Sorter
class. Test your solution in the main function.
Examples of sortable types:
- Complex numbers. Should be sorted by absolute value (length of the vector).
- Rational numbers as a ratio of two integers p/q. Numerical sorting is well defined.
- 3D vectors. Should be sorted by length.
Completing one or both optional tasks can make up for mistakes in the first task.