Overview: In this problem, you will emulate the push_back function of the C vector class. We will call this function append . This function will insert an element to an array at the smallest vacant index. In case the array is full, the function should perform array doubling and then insert the element to the new array.
Unlike the resize function (Recitation 3 exercise), here you will not be returning a pointer after doubling the array. Instead, a reference-to-array pointer will be passed to your function append , so that you can modify the pointer to the array itself. The function should return true if array doubling was performed, otherwise return false.
Use the function prototype provided below:
bool append(string* &str_arr, string s, int &numEntries, int &arraySize);
INPUT PARAMETERS:
→ str_arr is an array of type string in which you insert elements. A reference to this array pointer is passed to your function.
→s is a new string that you want to insert in your string array
→ numEntries keeps track of the number of elements that have been inserted in your array so far
→ array Size variable stores the current size of your array
OUTPUT PARAMETERS:
→ doubled is just a boolean value true or false
You return true if array has been doubled else return false
You are also required to update the variable numEntries and array Size within the function:
→ Update numEntries when you add a new element to the array.
→ Update array Size whenever you perform array doubling.