Typically, for a static array, we would have a third variable that stores the nu
ID: 3744185 • Letter: T
Question
Typically, for a static array, we would have a third variable that stores the number of elements used. However, dynamic arrays allow us to bypass this requirement. Create an array of 5 names. The names, or strings, can be whatever you would like. Create a function that removes a certain string/name with a given location. It may look like this. string* deleteEntry(string *array, int& size, int loc) The function will first create a new dynamic array, copy all the values except for one at the location given, and decrease the size. This will only be done if the location is actually valid, so proper error checking is needed. Finally, it will return the new dynamic array. Create a driver that tests if your function performed correctly. in C++
Explanation / Answer
#include #include using namespace std; string* deleteEntry(string *array, int& size, int loc) { if(loc >= 0 && locRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.