Question: 2. Below is the class dcclaration for the Bag class from your text. Refer to this header file to answer parts a and b. /**

 2. Below is the class dcclaration for the Bag class fromyour text. Refer to this header file to answer parts a andb. /** ADT bag: Array-based implementation. @file Bag.h 7 #ifndef _BAG #define

2. Below is the class dcclaration for the Bag class from your text. Refer to this header file to answer parts a and b. /** ADT bag: Array-based implementation. @file Bag.h 7 #ifndef _BAG #define _BAG template class Bag private: static const int DEFAULT_BAG_SIZE = 6; Item Type items (DEFAULT_BAG_SIZE); Il array of Bag items int itemCount; Il current count of Bag items int maxitems; Il max capacity of the Bag // Returns either the index of the element in the array items that Il contains the given target or -1, if the array does not contain // the target. int getindexOf(const Item Type& target) const; public: l/construct an empty bag Bag(); //returns number of elements in the Bag int getCurrent Sizel ) const; //returns true if Bag is empty, false otherwise bool isEmpty() const; // adds newEntry to Bag bool add(const Item Type& newEntry); //removes first occurrence of anEntry from Bag bool remove(const Item Type& anEntry); Il empties the Bag void clear(); l/returns true if Bag contains anEntry, false otherwise bool contains(const Item Type& anEntry) const: Il returns the number of occurrences of anEntry in the Bag int getFrequency Of(const Item Type & an Entry) const; Il implementation NOT shown Meridif 1) Add a constructor to the Bag class that creates a bag from a given array of entries. 2) /NWrite the constructor protoype (declaration) that should be added to the header file Bag.h. 3) Wrtite the complete definition of the new constructor that should be added to implementation file I/Bag.cpp. //THIS IS NOT ACCEPTED, PLEASE DO IT WITHOUT POINTER // Method to replace() //THIS IS NOT ACCEPTED, PLEASE DO IT WITHOUT POINTER bool relpace(int x,int location, int *bag[]) // THIS IS NOT ACCEPTED, PLEASE DO IT WITHOUT POINTER int i=0; // THIS IS NOT ACCEPTED, PLEASE DO IT WITHOUT POINTER while(i class Bag private: static const int DEFAULT_BAG_SIZE = 6; Item Type items (DEFAULT_BAG_SIZE); Il array of Bag items int itemCount; Il current count of Bag items int maxitems; Il max capacity of the Bag // Returns either the index of the element in the array items that Il contains the given target or -1, if the array does not contain // the target. int getindexOf(const Item Type& target) const; public: l/construct an empty bag Bag(); //returns number of elements in the Bag int getCurrent Sizel ) const; //returns true if Bag is empty, false otherwise bool isEmpty() const; // adds newEntry to Bag bool add(const Item Type& newEntry); //removes first occurrence of anEntry from Bag bool remove(const Item Type& anEntry); Il empties the Bag void clear(); l/returns true if Bag contains anEntry, false otherwise bool contains(const Item Type& anEntry) const: Il returns the number of occurrences of anEntry in the Bag int getFrequency Of(const Item Type & an Entry) const; Il implementation NOT shown Meridif 1) Add a constructor to the Bag class that creates a bag from a given array of entries. 2) /NWrite the constructor protoype (declaration) that should be added to the header file Bag.h. 3) Wrtite the complete definition of the new constructor that should be added to implementation file I/Bag.cpp. //THIS IS NOT ACCEPTED, PLEASE DO IT WITHOUT POINTER // Method to replace() //THIS IS NOT ACCEPTED, PLEASE DO IT WITHOUT POINTER bool relpace(int x,int location, int *bag[]) // THIS IS NOT ACCEPTED, PLEASE DO IT WITHOUT POINTER int i=0; // THIS IS NOT ACCEPTED, PLEASE DO IT WITHOUT POINTER while(i

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!