***Please use values between 0 and 9.***
Enter an offset (0-9) and a value. (-1 to stop): -1 -1
intArray:...
[0] 0
[1] 10
[2] 20
[3] 30
[4] 40
[5] 50
[6] 60
[7] 70
[8] 80
[9] 90
animalArray:...
[0] 0
[1] 100
[2] 200
[3] 300
[4] 400
[5] 500
[6] 600
[7] 700
[8] 800
[9] 900
Most of the Arrayclass implementation is left out to save space. The Animal
class is declared on lines 7–24. Although this is a stripped-down and simplified
class, it does provide its own insertion operator (<<) to allow the printing of Animals. As
you can see in the definition of the insertion operator on lines 27–32, printing simply
prints the current weight of the Animal.
Note that Animalhas a default constructor. This is necessary because, when you add an
object to an array, the object’s default constructor is used to create the object. This cre-
ates some difficulties, as you’ll see.
On line 103, the function IntFillFunction()is declared. The prototype indicates that
this function takes an integer Array. Note that this is not a template function.
IntFillFunction()expects only one type of an Array—an integer array. Similarly, on
line 104,AnimalFillFunction()is declared to take an Arrayof Animal.
The implementations for these functions are different from one another because filling an
array of integers does not have to be accomplished in the same way as filling an array of
Animals.
682 Day 19
ANALYSIS