< previous page page_425 next page >

Page 425
LISTING 24.1 continued
d5ef64f4d3250b96ba5c07ca5bbc2f56.gif
6:      class xBoundary
7:      {
8:      public:
9:         xBoundary() {}
10:        ~xBoundary() {}
11:     private:
12:     };
13:
14:
15:     class Array
16:     {
17:     public:
18:         // constructors
19:         Array(int itsSize = DefaultSize);
20:         Array(const Array &rhs);
21:         ~Array() { delete [] pType;}
22:
23:         // operators
24:         Array& operator=(const Array&);
25:         int& operator[](int offSet);
26:         const int& operator[](int offSet) const;
27:
28:         // accessors
29:         int GetitsSize() const { return itsSize; }
30:
31:         // friend function
32:         friend ostream& operator<< (ostream&, const Array&);
33:
34:     private:
35:         int *pType;
36:         int itsSize;
37:     };
38:
39:
40:     Array::Array(int size):
41:       itsSize(size)
42:       {
43:          pType = new int[size];
44:          for (int i = 0; i<size; i++)
45:             pType[i] = 0;
46:       }
47:
48:
49:     Array& Array::operator=(const Array &rhs)
50:     {
51:          if (this == &rhs)
52:             return *this;
53:          delete [] pType;
54:          itsSize = rhs.GetitsSize();
d5ef64f4d3250b96ba5c07ca5bbc2f56.gif
continues

 
< previous page page_425 next page >

If you like this book, buy it!