Question: An Elastic Array In lab, you created a DynamicArray class that allows an array of any size to be created at runtime. The class used

 An "Elastic" Array In lab, you created a DynamicArray class thatallows an array of any size to be created at runtime. Theclass used the concept of RAll by utilizing a destructor to ensurethat the dynamically-allocated internal storage array was properly deleted when it leftmemory In this exercise, you will create an ElasticArray that will beable to grow or shrink on demand (much like std: :vector), andthen explore how iterators are designed by wrapping an observing pointer tothe ElasticArray 's internal storage. Create ElasticArray Start by copying the DynamicArraycode you created for the in-lab assignment into a new header and

An "Elastic" Array In lab, you created a DynamicArray class that allows an array of any size to be created at runtime. The class used the concept of RAll by utilizing a destructor to ensure that the dynamically-allocated internal storage array was properly deleted when it left memory In this exercise, you will create an ElasticArray that will be able to grow or shrink on demand (much like std: :vector), and then explore how iterators are designed by wrapping an observing pointer to the ElasticArray 's internal storage. Create ElasticArray Start by copying the DynamicArray code you created for the in-lab assignment into a new header and implementation file pair (ElasticArray.h and ElasticArray.cpp). Change all references to DynamicArray to ElasticArray by careful use of find-and-replace. Your class interface should now look like this class ElasticArrayf public: ElasticArray (int size) int size() const f return size; ) int& at(int i) BlasticArray) private: int*-array nullptr; int size0; Create a new, empty main testing program for this project. Add the code necessary to verity that the ElastieArray class works the same as the DynamieArray class from the lab. (Here, you are just verifying that no mistakes were introduced during the re-naming procedure.) ElasticArray Description When you are finished, the ElasticArray class will be able to do these things that the DynamicArray class could not do: ElasticArray will be default-constructable ElasticArray will be copy-constructable. ElasticArray will be copy-assignable and will exhibit correct 'by-value" semantics. ElasticArray will implement: a push back method that will allow new items to be added at the end of the array. front ) and back ) methods that will allow the items at the front and back (respectively) of the array to be accessed a pop back ) method that will return the value of the item at the back of the array and then remove that item from the array. a shrink_to fit() method that will reduce the internal storage of the object to exactly match the current logical array size Now we will look at some details about how to make each of these features a reality. Notice that we will not necessarily implement them in the order they are listed. Sometimes it is better to choose an order of implementation that will allow you more freedom to test and debug incrementally as you go along. An "Elastic" Array In lab, you created a DynamicArray class that allows an array of any size to be created at runtime. The class used the concept of RAll by utilizing a destructor to ensure that the dynamically-allocated internal storage array was properly deleted when it left memory In this exercise, you will create an ElasticArray that will be able to grow or shrink on demand (much like std: :vector), and then explore how iterators are designed by wrapping an observing pointer to the ElasticArray 's internal storage. Create ElasticArray Start by copying the DynamicArray code you created for the in-lab assignment into a new header and implementation file pair (ElasticArray.h and ElasticArray.cpp). Change all references to DynamicArray to ElasticArray by careful use of find-and-replace. Your class interface should now look like this class ElasticArrayf public: ElasticArray (int size) int size() const f return size; ) int& at(int i) BlasticArray) private: int*-array nullptr; int size0; Create a new, empty main testing program for this project. Add the code necessary to verity that the ElastieArray class works the same as the DynamieArray class from the lab. (Here, you are just verifying that no mistakes were introduced during the re-naming procedure.) ElasticArray Description When you are finished, the ElasticArray class will be able to do these things that the DynamicArray class could not do: ElasticArray will be default-constructable ElasticArray will be copy-constructable. ElasticArray will be copy-assignable and will exhibit correct 'by-value" semantics. ElasticArray will implement: a push back method that will allow new items to be added at the end of the array. front ) and back ) methods that will allow the items at the front and back (respectively) of the array to be accessed a pop back ) method that will return the value of the item at the back of the array and then remove that item from the array. a shrink_to fit() method that will reduce the internal storage of the object to exactly match the current logical array size Now we will look at some details about how to make each of these features a reality. Notice that we will not necessarily implement them in the order they are listed. Sometimes it is better to choose an order of implementation that will allow you more freedom to test and debug incrementally as you go along

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!