Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

10. Suppose you are implementing a customer designed container called Dec as a w

ID: 3937947 • Letter: 1

Question

10. Suppose you are implementing a customer designed container called Dec as a wrapper around an STL list. 10 a) (10 pts) Complete the following class declaration (Write only the prototypes and the private data field; definitions will follow the class declaration): template class Dec public: // hasDuplicate function that returns true if the private data member has an item that appears twice or more in the list. // eraseAll function to remove all items which are equal to the item specified in the function parameter // isLessThan function to determine if another Dec object is greater than the Dec object itself. If the summation of all items from the Dec object itself is less than the summation of all items from another Dec object, return true, otherwise, return false. // push_second function to add an item after the first iten if there are more than one items private: // list to hold the elements of the dec

Explanation / Answer

Here is the code for your first part:

#include <vector>
using namespace std;
template <typename ElementType>
class Dec
{
public:
   //hasDuplicate function that returns true if the private data member has an item that appears twice or more in the list.
   bool hasDuplicate();
   //eraseAll function to remove all items which are equal to the item specified in the function parameter.
   void eraseAll(ElementType element);
   //isLessThan function to determine if another Dec object is greater than the Dec object itself.
   //If the summation of all items from the Dec object itself is less than the summation of all
   //items from another Dec object, return true, otherwise, return false.
   bool isLessThan(Dec other);
   //push_second function to add an item after the first item if there are more than one items.
   void push_second(ElementType element);
private:
vector<ElementType> dec;
};

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at drjack9650@gmail.com
Chat Now And Get Quote