< previous page page_431 next page >

Page 431
LISTING 24.2 continued
d5ef64f4d3250b96ba5c07ca5bbc2f56.gif
49:      public:
50:         xNegative(int size):xSize(size){}
51:         virtual void PrintError()
52:          { cout << Negative! Received: ;
53:            cout << xSize::itsSize << end1; }
54:      };
55:
56:
57:      class Array
58:      {
59:      public:
60:         // constructors
61:         Array(int itsSize = DefaultSize);
62:         Array(const Array &rhs);
63:         ~Array() { delete [] pType;}
64:
65:         // operators
66:         Array& operator=(const Array&);
67:         int& operator[](int offSet);
68:         const int& operator[](int offSet) const;
69:
70:         // accessors
71:         int GetitsSize() const { return itsSize; }
72:
73:         // friend function
74:         friend ostream& operator<< (ostream&, const Array&);
75:
76:
77:      private:
78:         int *pType;
79:         int itsSize;
80:      };
81:
82:      Array::Array(int size):
83:      itsSize(size)
84:      {
85:         if (size == 0)
86:            throw xZero(size);
87:
88:         if (size < 0)
89:            throw xNegative(size);
90:
91:         if (size < 10)
92:            throw xTooSmall(size);
93:
94:         if (size > 30000)
95:            throw xTooBig(size);
96:
97:
d5ef64f4d3250b96ba5c07ca5bbc2f56.gif
continues

 
< previous page page_431 next page >

If you like this book, buy it!