< previous page page_426 next page >

Page 426
LISTING 24.1 continued
d5ef64f4d3250b96ba5c07ca5bbc2f56.gif
55:        pType = new int[itsSize];
56:        for (int i = 0; i<itsSize; i++)
57:           pType[i] = rhs[i];
58:        return *this;
59:     }
60:
61:     Array::Array(const Array &rhs)
62:     {
63:        itsSize = rhs.GetitsSize();
64:        pType = new int[itsSize];
65:        for (int i = 0; i<itsSize; i++)
66:           pType[i] = rhs[i];
67:     }
68:
69:
70:     int& Array::operator[](int offSet)
71:     {
72:        int size = GetitsSize();
73:        if (offSet >>= 0 && offSet < GetitsSize())
74:           return pType[offSet];
75:        throw xBoundary();
76:        return pType[offSet]; // to appease MSC!
77:
78:     }
79:
80:
81:     const int& Array::operator[](int offSet) const
82:     {
83:        int mysize = GetitsSize();
84:        if (offSet >>= 0 && offSet < GetitsSize())
85:           return pType[offSet];
86:        throw xBoundary();
87:        return pType[offSet]; // to appease MSC!
88:     }
89:
90:     ostream& operator<< (ostream& output, const Array& theArray)
91:     {
92:        for (int i = 0; i<theArray.GetitsSize(); i++)
93:           output << [ << i << ] << theArray[i] << end1;
94:        return output;
95:     }
96:
97:     int main()
98:     {
99:        Array intArray(20);
100:       try
101:        {
102:           for (int j = 0; j< 100; j++)
103:           {
d5ef64f4d3250b96ba5c07ca5bbc2f56.gif
continues

 
< previous page page_426 next page >

If you like this book, buy it!