Problem

Programming Exercise processes only int arrays. Redesign the class safeArray using class t...

Programming Exercise processes only int arrays. Redesign the class safeArray using class templates so that the class can be used in any application that requires arrays to process data.

Programming Exercise

(Safe Arrays) In C++, there is no check to determine whether the array index is out of bounds. During program execution, an out-of-bound array index can cause serious problems. Also, recall that in C++ the array index starts at 0.

Design a class safeArray that solves the out-of-bound array index problem and allows the user to begin the array index starting at any integer, positive or negative. Every object of type safeArray should be 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. For example,

safeArray list (2, 13);safeArray yourList(−5, 9);

In this example, list is an array of 11 components, … the component type is int , and the components are list[2] , list[3], …, list[12] . Also, yourList is an array of 15 components, the component type is int, and the components are yourList [−5], yourlist[−4], …, yourList[0], …, yourList[8].

Step-by-Step Solution

Request Professional Solution

Request Solution!

We need at least 10 more requests to produce the solution.

0 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the solution will be notified once they are available.
Add your Solution
Textbook Solutions and Answers Search
Solutions For Problems in Chapter 3
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT