Write a new Checkbook class that uses a dynamic array. Call the class a differen
ID: 3698051 • Letter: W
Question
Write a new Checkbook class that uses a dynamic array. Call the class a different name, since it will be different from the latest version that uses a static array. Start off with a dynamic array size of 2, made by the constructor. Every time the dynamic array becomes full and a new check has to be written, double the current size of the array. Write a doubleArray function for the class to do this, but place the function prototype in the private section, since you don’t want the client to call the function. Keep a pointer to the dynamic array in the private section. Write a getChecks function that will return a pointer to DataType (which is going to be the address of a dynamic array). Create a dynamic array in the getChecks function, copy the checks to it, and return the pointer to this dynamic array (so that you return its address). Do not return the pointer in the private section, because you don’t want the client to access (or possibly change) the saved array. Note that the dynamic array created in the getChecks function will not be destroyed at the end of the function; only the local pointer that points to it will. The client will receive the address of this dynamic array created in the getChecks function, however, and will be able to use the array. Write a comment which makes it clear that the client must free the dynamic array when the client is done with it (to prevent memory leak). Use a Check struct of your own design to test the class template.
Explanation / Answer
which language ?
please post Checkbook class that uses a static array.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.