The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | Apr 2017 |
| Last Sign in: | 103 Weeks Ago, 3 Days Ago |
| Questions Answered: | 4870 |
| Tutorials Posted: | 4863 |
MBA IT, Mater in Science and Technology
Devry
Jul-1996 - Jul-2000
Professor
Devry University
Mar-2010 - Oct-2016
help with this C++Â Data Structure assignment. Please read the attached instructions carefully before accepting this.
Â
The SafeArray ProjectRecall that there is no check on an array index out of bounds.However, during programexecution, an array index out of bounds can cause serious problems. Also, in C++, the arrayindexes starts at 0.Design and implement the templatedclass SafeArraythat solves the array index out ofbounds problem and also allows the user to begin the array indexes to start at an arbitraryindex a and end at an arbitrary index b-1, provided a < b. These integers may be negativeEvery object of this class represents an array of values of the template type.The templatedclass should be contained in a file namedSafeArray.h.That MUST be the name with nomodifications.The private section of the class declaration is as follows:int firstValid;int firstInvalid;T *A;You will use a dynamic array A to implement the SafeArray objects.Moreover, the user will beable to use indexes i withfirstValidIndex <= i < firstInvalidIndex.This means that your code for the [ ] operator will have to translate these indices to ones thatstart at 0.Consider the following statements:SafeArray<int> myArray(5);//Line 1firstValidIndex 0//firstInvalidIndex 5SafeArray<int> myMyArray(2, 13);//Line 2firstValidIndex 2//firstInvalidIndex 13SafeArray<int> yourArray(-5, 9);//Line 3 firstValidIndex -5//firstInvalidIndex 9The statement in Line 1 declareslistto be an array of 5 components, the component type isint, and the valid index references are:myArray[0], myArray[1], ..., myArray[4].The statement in Line 2 declaresmyArrayto be an array of 11 components, the componenttype isint, and the valid index references are:myMyArray[2], myMyArray[3], ..., myMyArray[12].The statement in Line 3 declaresyourArrayto be an array of 14 components, thecomponent type isint, and the valid index references are:yourArray[-5], yourArray[-4], ..., yourArray[0], ..., yourArray[8].
Attachments:
-----------