121:
122:
123: void IntFillFunction(Array<int>& theArray);
124: void AnimalFillFunction(Array<Animal>& theArray);
125:
126: int main()
127: {
128: Array<int> intArray;
129: Array<Animal> animalArray;
130: IntFillFunction(intArray);
131: AnimalFillFunction(animalArray);
132: cout << “intArray...\n” << intArray;
133: cout << “\nanimalArray...\n” << animalArray << endl;
134: return 0;
135: }
136:
137: void IntFillFunction(Array<int>& theArray)
138: {
139: bool Stop = false;
140: int offset, value;
141: while (Stop == false)
142: {
143: cout << “Enter an offset (0-2) and a value. “;
144: cout << “(-1 to stop): “ ;
145: cin >> offset >> value;
146: if (offset < 0)
147: break;
148: if (offset > 2)
149: {
150: cout << “***Please use values between 0 and 2.***\n”;
151: continue;
152: }
153: theArray[offset] = value;
154: }
155: }
156:
157:
158: void AnimalFillFunction(Array<Animal>& theArray)
159: {
160: Animal * pAnimal;
161: for (int i = 0; i<theArray.GetSize(); i++)
162: {
163: pAnimal = new Animal(i*10);
164: theArray[i] = *pAnimal;
165: delete pAnimal;
166: }
167: }
686 Day 19
LISTING19.6 continued