< previous page page_432 next page >

Page 432
LISTING 24.2 continued
d5ef64f4d3250b96ba5c07ca5bbc2f56.gif
98:         pType = new int[size];
99:         for (int i = 0; i<size; i++)
100:           pType[i] = 0;
101:      }
102:
103:      int& Array::operator[] (int offset)
104:      {
105:         int size = GetitsSize();
106:         if (offset >= 0 && offset < GetitsSize())
107:            return pType[offset];
108:         throw xBoundary();
109:        return pType[offset];
110:      }
111:
112:      const int& Array::operator[] (int offset) const
113:      {
114:         int size = GetitsSize();
115:         if (offset >= 0 && offset < GetitsSize())
116:            return pType[offset];
117:         throw xBoundary();
118:         return pType[offset];
119:      }
120:
121:      int main()
122:      {
123:
124:         try
125:         {
126:            int choice;
127:            cout << Enter the array size: ;
128:            cin >> choice;
129:            Array intArray(choice);
130:            for (int j = 0; j< 100; j++)
131:            {
132:               intArray[j] = j;
133:               cout << intArray[ << j << ] okay << end1;
134:            }
135:         }
136:         catch (xBoundary)
137:         {
138:            cout << Unable to process your input!\n;
139:         }
140:         catch (xSize& theException)
141:         {
142:            theException.PrintError();
143:         }
144:         catch ()
145:         {
d5ef64f4d3250b96ba5c07ca5bbc2f56.gif
continues

 
< previous page page_432 next page >

If you like this book, buy it!