Just some background information, I've currently made sorting algorithms for heap sort, quick sort and bubble sort. They work perfectly fine when used with the class below:
I've done this so far, but my sorting algorithms won't work properly without the commented out section being included (shown below), however apparently I should be able to use the functions from the initial class apart from overloading [] apparently.
Are you sure that you don't actually want to change SortableContainer from a container of double to a container of IntegerCoordinate? It doesn't make any sense for IntegerCoordinate to inherit from SortableContainer of double.
That does make more sense but it's an exercise and apparently it should work by just overloading [] to work with the previous functions? I'm honestly not sure, if its possible...
That does make more sense but it's an exercise and apparently it should work by just overloading [] to work with the previous functions? I'm honestly not sure, if its possible...
It is possible if the idea is to interpret or convert the individual elements of the existing vector of doubles to IntegerCoordinates. It is not possible if you just want to add in another data member via inheritance and reuse the existing code.
It would make more sense to convert the class to a template class where the type contained is specified by a template parameter, so it could work with doubles or IntegerCoordinates. Then, of course, you'd have to get creative with initialise_random (probably by moving it out of the class since that functionality doesn't really belong in a container.)