Question: Create a class IntBag which holds all integers in a dynamic array of default capacity of 100 elements. There are two constructors(default constructor and copy

 Create a class IntBag which holds all integers in a dynamic

Create a class IntBag which holds all integers in a dynamic array of default capacity of 100 elements. There are two constructors(default constructor and copy constructor), assignment operator= (which does the same work as copy constructor but uses b = a, where 'a' is already an object of the class IntBag), overloaded index [] operator and following member functions: a. add(int item) - adds item to the end of array, resizes it twice its current capacity if there is no more space b. getSize() - returns current size of an array c.setSize (int size) - sets array size d. fill(int c) fills all array's memory with a given integer e. clear() - removes all elements from the array, resets memory allocation f. delete(int pos) - deletes specified element from the array Partial implementation of the class is given below: class IntBag { const static int CAPACITY = 128; // initial size of array memory // (elements) const static int MULT = 2; // multiplier (enlarge array memory MULT times) public: IntBag(); // constructor IntBag(const IntBag &a); // copy constructor IntBag(); // destructor IntBag& operator = (const IntBag& a); // assignment operator int operator [] (int index); // get array item void add(const int item); // Add item to the end of array int getSize() const; // get size of array (elements) void setSize(int newsize); // set size of array (elements) void clear(); // clear array void delete(int pos); // delete array item private: int* array.; // pointer for array's memory int size_; // size of array (elements) // use whatever other members you need }

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!