Problem

One problem with dynamic arrays is that once the array is created using die new operator,...

One problem with dynamic arrays is that once the array is created using die new operator, the size cannot be changed. For example, you might want to add or delete entries from the array as you can with a vector. This project asks you to create functions that use dynamic arrays to emulate the behavior of a vector.

First, write a program that creates a dynamic array of five strings. Store five names of your choice into the dynamic array. Next, complete the following two functions:

string* addEntry(string -dynamicArray, int &size, string newEntry);

This function should create a new dynamic array one element larger than dynamic Array, copy all elements from dynamic Array into the new array, add the new entry onto the end of the new array, increment size, delete dynamic Array, and return the new dynamic array.

string* deleteEntry(string -dynamic Array, int &size, string entryToDelete);

This function should search dynamicArray for entryToDelete. If not found, the request should be ignored and die unmodified dynamicArray returned. If found, create a new dynamic array one element smaller than dynamicArray. Copy all elements except entryToDelete into the new array, delete dynamicArray, decrement size, and return the new dynamic array.

Test your functions by adding and deleting several names to the array while outputting the contents of the array. You will have to assign the array returned by addEntry or deleteEntry back to the dynamic array variable in your main function.

Step-by-Step Solution

Request Professional Solution

Request Solution!

We need at least 10 more requests to produce the solution.

0 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the solution will be notified once they are available.
Add your Solution
Textbook Solutions and Answers Search
Solutions For Problems in Chapter 9
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT