Question: We all low that the regular array has wealnesses, such as the size has to be known when declaring it (constant), the indices have to

 We all low that the regular array has wealnesses, such as

the size has to be known when declaring it (constant), the indices

We all low that the regular array has wealnesses, such as the size has to be known when declaring it (constant), the indices have to start with zero, there is no boundary checking. Now we would like you to design a customized array type, called Safe Array, to overcome these wealnesses. Even better we want Safe Array be a class template that stores an aray of any type of thing it works on, rather than creating a set of type-specific arrays-an intArray is an array of integers; a floatArray is an array of floats; a catAray is an array of cats. SafeArray is a parameterized template that provides you with the ability to create a general aray class and pass types as parameters to that class to build specific instances. We use the class name SA, short for SafeArray. The SA template class has following features: The memory for array elements is always allocated from dynamic memory area, ie freestore. And the size of array is determined during the run time The index of element s in this array does not have to start with zero. Using wrong index (out of bounds) when accessing array elements will not cause any serious consequences, instead just pop up proper enror messages if the index goes out of bounds. The skeleton of the SA template is as follows, but you need to add and implement the additional member functions listed below it. const int dSize = 10; // default size template class SA I private // pointer of T type int lldx: / low index int hIdx: / high index public: // the following nine member funtions go here SA ( indexed between 0 and 9. [default constructor] )-will allocate a l D T array in freestore with default size of 10 and which can be 1. 2. SA int n -will allocate a 1D T aray in freestore with size of n and which can be 3. 4. SA const SA& arr-will make a separate copy of SafeArray a with the same size 5, indexed between 0 and n1. [1 parameter constructor] SA ( int 1, int h )-will allocate a 1D T array in teestore with size of (h-l+ 1) and which can be indexed between I and h. [2 parameter constructor] and indexing as arr. [copy constructor] operator=( const SAs rhs )-assignment operator -SA ( )-will release the memory space allocated for te ID T array from dynamic memory freestore. [destructor] 6

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!