Question: Methods 1. default constructor - creates an array of strings of size 4 in dynamic memory and assigns its address to the class' string pointer,

Methods 1. default constructor - creates an array of strings of size 4 in dynamic memory and assigns its address to the class' string pointer, sets maximum size to 4, and current size to 0. 2. copy constructor - creates a deep copy of its constant StringList reference parameter. 3. destructor - deallocates dynamic memory associated with the object's string (array) pointer. 4. overloaded assignment operator - deep copies its constant StringList reference parameter to the calling object; deallocates dynamic memory associated with the calling object's original array; returns a reference to the calling object; should behave correctly during self-assignment. 5.insert - inserts its string parameter (the first parameter) at the index specified by its integer parameter (the second parameter). Before insertion all array element at or above the insertion point are moved up one position in the array (to make space for the inserted value). If the underlying array is full before the insertion it first doubles the maximum size attribute, creates an array of twice the size of the current array, copies the contents of the old array to the new array, frees memory associated with the old array, and assigns new array's address to object's array pointer, then inserts the string and increments current size. If the index parameter is less than 0 or greater than the current size the method should throw an out_of_range exception. 6. remove - returns the string stored at the index given by its integer parameter. Moves down all array elements above the index by one position in the array (thereby overwriting the removed value) and decrements current size. If the index parameter is less than 0 or greater than current size-1 the method should throw an out_of_range exception. 7. swap - swaps the two array elements stored at the indexes given by its two integer parameters. If either index parameter is less than 0 or greater than current size-1 the method should throw an out_of_range exception. 8. retrieve- returns the string stored at the index given by its integer parameter. If the index parameter is less than 0 or greater than current size-1 the method should throw an out_of_range exception. 9. size - returns an integer equal to the number of values in the calling object. 10. concatenate - returns a StringList object that contains the contents of the calling object followed by the contents of its constant StringList reference parameter; the size of the returned object's underlying array should be the greater of 4 and the number of values stored in it. Attributes Your class should be implemented with a dynamic array and should have the following private member variables A pointer to a string that will be used to point to an array of strings in dynamic memory An int that records the current size of the array (the number of values stored in the array) An int that records the maximum size of the array Notes The calling object should be made constant (const) for any method where the calling object's attribute values should not change Method parameters and return values are noted in the method descriptions - you must not add additional parameters to the methods; if the method description does not mention a parameter it does not have one, similarly if no return value is mentioned the method is void (or a constructor or destructor). Methods must be given the same names as shown above
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
