Question: In the code snippet below, the array arr is declared in line #7 with a size of 4 with 4 initial values also defined. However,
In the code snippet below, the array
arr
is declared in line #7 with a size of 4
with 4 initial values also defined.

However, in line #9 to #11, the arrays are accessed to be printed. The loop is
set at SIZE+2 in line #9 which means that we will access values beyond that of
the array. C++ does not check for out-of-bound access in an array.
Output printed from the loop in #9 to #11 is shown below.

Last two values are invalid because they are values beyond the array.
You will now define an array that will check for the array bounds.
Design an array called
myArray
according to this declaration.

Here is definition of empty constructor in line #13

Here is definition of constructor in line #11 specifying the upper bound of the
array




4 const int SIZE=4; 6 int main() int arr[SIZE] {3,14, 7,81); = 8 9, 10 for(int 1-0;1
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
