Please assist with the following problem. I am totally lost with this so if you could also include statements telling me what you did, I would appreciate it. The entire chapter talks about array index out of bounds which has completely confused me and there are no examples in the book to help. If you could complete this program, it will help me to better understand how this works and what it is used for.
Design and implement the class myArray that solves the array index out of bound problem and also allows the user to begin the array index starting at any integer, positive or negative. Every object of the type myArray is an array of type int. During execution, when accessing an array component, if the index is out of bounds, the program must terminate with an appropriate error message. Consider the following statements;
myArray<int> list(5); //Line 1
myArray<int> myList(2,13); //Line 2
myArray<int> yourList(-5,9); //Line 3
The statement in line 1 declares list to be an array of 5 components, the component type is int, and the components are: list , list , ..., list ;
The statement in line 2 declares myList to be an array of 11 components, the component type is int, and the components are;
myList, myList, ..., myList;
the statement in line 3 declares yourList to be an array of 14 components, the component type is int, and the componest are:
yourList[-5], yourList[-4], ..., yourList, ..., yourList.
Write a program to test the class myArray.© BrainMass Inc. brainmass.com July 15, 2018, 9:16 pm ad1c9bdddf
The solution examines an array index out of bounds.