66: if (offSet >= 0 && offSet < GetitsSize())
67: return pType[offSet];
68: throw xBoundary();
69: return pType[0]; // appease MSC
70: }
71:
72: const int& Array::operator[](int offSet) const
73: {
74: int mysize = GetitsSize();
75: if (offSet >= 0 && offSet < GetitsSize())
76: return pType[offSet];
77: throw xBoundary();
78: return pType[0]; // appease MSC
79: }
80:
81: ostream& operator<< (ostream& output, const Array& theArray)
82: {
83: for (int i = 0; i<theArray.GetitsSize(); i++)
84: output << “[“ << i << “] “ << theArray[i] << endl;
85: return output;
86: }
87:
88: int main()
89: {
90: Array intArray(20);
91: try
92: {
93: for (int j = 0; j< 100; j++)
94: {
95: intArray[j] = j;
96: cout << “intArray[“ << j << “] okay...” << endl;
97: }
98: }
99: catch (Array::xBoundary)
100: {
101: cout << “Unable to process your input!” << endl;
102: }
103: cout << “Done.” << endl;
104: return 0;
105: }
intArray[0] okay...
intArray[1] okay...
intArray[2] okay...
intArray[3] okay...
intArray[4] okay...
intArray[5] okay...
intArray[6] okay...
OUTPUT
726 Day 20
LISTING20.4 continued