Question

1. A) You have this function that sorts any vector of char data: void good_bubble(vector<char> &...

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...)

Homework Answers

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
C++ Class involving difference. The goal is to overload the function: void Bag::operator-=(const Bag& a_bag) //...
C++ Class involving difference. The goal is to overload the function: void Bag::operator-=(const Bag& a_bag) // The Set Difference between two sets A and B is the set that consists of the elements of A which are not elements of B. Bag bag1 = (1,2,3) and Bag bag2 = (2,4,5) then bag1-=bag2 should return 1,3,4,5. //parameter a_bag to be subtracted from this (the calling) bag //post removes all data from items_ that is also found in a_bag //Since type is...
IntNode class I am providing the IntNode class you are required to use. Place this class...
IntNode class I am providing the IntNode class you are required to use. Place this class definition within the IntList.h file exactly as is. Make sure you place it above the definition of your IntList class. Notice that you will not code an implementation file for the IntNode class. The IntNode constructor has been defined inline (within the class declaration). Do not write any other functions for the IntNode class. Use as is. struct IntNode { int data; IntNode *next;...
in c++ : Problem Domain: The classic TicTacToe game alternatively place Xs and Os on a...
in c++ : Problem Domain: The classic TicTacToe game alternatively place Xs and Os on a 3x3 grid. The winner is the first player to place 3 consecutive marks in a horizontal, vertical or diagonal row. Understanding the Problem: In this assignment, you will: 1) Create a tic tac toe board data structure. 2) Check for game over. 3) Clear the tic tac toe game for each game. 4) Display the tic tac toe board to screen. 5) Simulate playing...
Write a program that sorts the content of a map by Values. Before we start, we...
Write a program that sorts the content of a map by Values. Before we start, we need to check the explanation of Java Map Interface and Java LinkedHashMap. This program can be implemented as follows: 1. Create a LinkedHashMap class <String (Country), String(Capital)> that stores Capitals of FIVE countries. 2. Use sortMap() for receiving content of the created class of LinkedHashMap and reorder it in a sorted Map. (sort in natural order). 3. You need to transfer the map into...
Something is either messed up in my operator overload <<, covertopostfix function, or my main output....
Something is either messed up in my operator overload <<, covertopostfix function, or my main output. Cannot figure it out. please help. Please comment your changes too. Program below is supposed to be outputting like this: InFix is:   A+B-C Post fix is:   A B + C - InFix is:   A+C Post fix is:   A C + InFix is:   x*(y+z)-(w+t) Post fix is:   x y z + * w t + - InFix is:   A+B*(C+D)-E/F+G+H Post fix is:   A B C...
Using the following code perform ALL of the tasks below in C++: ------------------------------------------------------------------------------------------------------------------------------------------- Implementation: Overload input...
Using the following code perform ALL of the tasks below in C++: ------------------------------------------------------------------------------------------------------------------------------------------- Implementation: Overload input operator>> a bigint in the following manner: Read in any number of digits [0-9] until a semi colon ";" is encountered. The number may span over multiple lines. You can assume the input is valid. Overload the operator+ so that it adds two bigint together. Overload the subscript operator[]. It should return the i-th digit, where i is the 10^i position. So the first...
Data Structures using C++ Consider the classes QueueADT and ArrayQueueType: QueueADT: #ifndef QUEUEADT_H #define QUEUEADT_H template...
Data Structures using C++ Consider the classes QueueADT and ArrayQueueType: QueueADT: #ifndef QUEUEADT_H #define QUEUEADT_H template <class ItemType> class QueueADT { public:        // Action responsibilities        virtual void resetQueue() = 0;           // Reset the queue to an empty queue.           // Post: Queue is empty.        virtual void add(const ItemType& newItem) = 0;           // Function to add newItem to the queue.           // Pre: The queue exists and is not full.          ...
Can someone please edit my code so that it satisfies the assignments' requirements? I pasted the...
Can someone please edit my code so that it satisfies the assignments' requirements? I pasted the codes below. Requirement: Goals for This Project:  Using class to model Abstract Data Type  OOP-Data Encapsulation You are asked to write an app to keep track of a relatively small music library. The app should load song information from a data file once the app is started. It should allow user to view, add, remove, and search for songs. The app should...
My assignment: Triplet Template Class Directions: Define a template class for a generic triplet. The private...
My assignment: Triplet Template Class Directions: Define a template class for a generic triplet. The private data member for the triplet is a generic array with three elements. The triplet ADT has the following functions:  default constructor  explicit constructor: initialize the data member using parameters  three accessors (three get functions) which will return the value of each individual element of the array data member  one mutator (set function) which will assign values to the data member...
Getting the following errors: Error 1 error C2436: '{ctor}' : member function or nested class in...
Getting the following errors: Error 1 error C2436: '{ctor}' : member function or nested class in constructor initializer list on line 565 Error 2 error C2436: '{ctor}' : member function or nested class in constructor initializer list on line 761 I need this code to COMPILE and RUN, but I cannot get rid of this error. Please Help!! #include #include #include #include using namespace std; enum contactGroupType {// used in extPersonType FAMILY, FRIEND, BUSINESS, UNFILLED }; class addressType { private:...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT