Question: c++ #, both myArray.h and myArrayimp.cpp. here is instruction. Please use the file names listed below since your file will have the following components: Ch13_Ex11_MainProgram.cpp

c++ #, both myArray.h and myArrayimp.cpp. here is instruction.

  1. Please use the file names listed below since your file will have the following components: Ch13_Ex11_MainProgram.cpp - given file

    #include #include "myArray.h"

    using namespace std;

    int main() { myArray list1(5); myArray list2(5);

    int i;

    cout << "list1 : "; for (i = 0 ; i < 5; i++) cout << list1[i] <<" "; cout<< endl;

    cout << "Enter 5 integers: "; for (i = 0 ; i < 5; i++) cin >> list1[i]; cout << endl;

    cout << "After filling list1: ";

    for (i = 0 ; i < 5; i++) cout << list1[i] <<" "; cout<< endl;

    list2 = list1; cout << "list2 : "; for (i = 0 ; i < 5; i++) cout << list2[i] <<" "; cout<< endl;

    cout << "Enter 3 elements: ";

    for (i = 0; i < 3; i++) cin >> list1[i]; cout << endl;

    cout << "First three elements of list1: "; for (i = 0; i < 3; i++) cout << list1[i] << " "; cout << endl;

    myArray list3(-2, 6);

    cout << "list3: "; for (i = -2 ; i < 6; i++) cout << list3[i] <<" "; cout<< endl;

    list3[-2] = 7; list3[4] = 8; list3[0] = 54; list3[2] = list3[4] + list3[-2];

    cout << "list3: "; for (i = -2 ; i < 6; i++) cout << list3[i] <<" "; cout<< endl; system("pause");

    return 0; } myArray.h myArrayImp.cpp

    Recall that in C++, there is no check on an array index out of bounds. However, during program execution, an array index out of bounds can cause serious problems. Also, in C++, the array index starts at 0.
  2. Design and implement the class myArray that solves the array index out of bounds problem and also allows the user to begin the array index starting at any integer, positive or negative.
    1. Every object of 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 list(5); //Line 1 myArray myList(2, 13); //Line 2 myArray 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[0], list[1], ..., list[4]; The statement in Line 2 declares myList to be an array of 11 com- ponents, the component type is int, and the components are: myList[2], myList[3], ..., myList[12]; The statement in Line 3 declares yourList to be an array of 14 components, the component type is int, and the components are: yourList[-5], yourList[-4], ..., yourList[0], ..., yourList[8].

  3. Write a program to test the class myArray.

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!