1.
A)
You have this function that sorts any vector of char data:
void good_bubble(vector<char> & data, vector<char>::size_type start, vector<char>::size_type end) { vector<char>::size_type loop{0}, cur; bool done{false}; while (loop <= end-start+1 && !done) { done = true; for (cur = start; cur <= end-1-loop; ++cur) { if (data[cur] > data[cur+1]) { swap(data[cur], data[cur+1]); done = false; } } ++loop; } return; }
But now you have to sort Date objects! As luck would have it, the Date class provides the method:
bool Date::greater(const Date & other) const;
Please show your changes to only the lines from above that would need to change to make your overload of good_bubble sort a vector of Date objects.
B) When you try to run the new good_bubble, you realize that there is one thing missing! Show your code for it here. (Hint: Something that is not library or language provided.) (Hmm... but should the missing function be a member or non-member of the Date class? Perhaps how it is used in the function above can give you a clue...)
Get Answers For Free
Most questions answered within 1 hours.