One problem with dynamic arrays is that once the array is created using the new operator the size cannot be changed. For example, you might want to add or delete entries from the array similar to the behavior of a vector . This project asks you to create a class called DynamicStringArray that includes member functions that allow it to emulate the behavior of a vector of strings. The class should have the following A private member variable called dynamicArray that references a dynamic array of type string. A private member variable called size that holds the number of entries in the array. A default constructor that sets the dynamic array to NULL and sets size to 0. A function that returns size . A function named addEntry that takes a string as input. The function should create a new dynamic array one element larger than dynamicArray , copy all elements from dynamicArray into the new array, add the new string onto the end of the new array, increment size, delete the old dynamicArray , and then set dynamicArray to the new array. A function named deleteEntry that takes a string as input. The function should search dynamicArray for the string. If not found, it returns false . If found, it creates a new dynamic array one element smaller than dynamicArray .It should copy all elements except the input string into the new array, delete dynamicArray , decrement size, and return true .

Programming Logic & Design Comprehensive
9th Edition
ISBN:9781337669405
Author:FARRELL
Publisher:FARRELL
Chapter10: Object-oriented Programming
Section: Chapter Questions
Problem 20RQ
icon
Related questions
Question

One problem with dynamic arrays is that once the array is created using the new operator the size cannot be changed. For example, you might want to add or delete entries from the array similar to the behavior of a vector . This project asks you to create a class called DynamicStringArray that includes member functions that allow it to emulate the behavior of a vector of strings.

The class should have the following

A private member variable called dynamicArray that references a dynamic array of type string.

A private member variable called size that holds the number of entries in the array.

A default constructor that sets the dynamic array to NULL and sets size to 0.

A function that returns size .

A function named addEntry that takes a string as input. The function should create a new dynamic array one element larger than dynamicArray , copy all elements from dynamicArray into the new array, add the new string onto the end of the new array, increment size, delete the old dynamicArray , and then set dynamicArray to the new array.

A function named deleteEntry that takes a string as input. The function should search dynamicArray for the string. If not found, it returns false . If found, it creates a new dynamic array one element smaller than dynamicArray .It should copy all elements except the input string into the new array, delete dynamicArray , decrement size, and return true .

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Array
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage