|
| |
What are...
arrays are collections of objects (variables) of same class
(type). The set is designated by a common name, and each object is designated by its
position in the set (index).
How could we have 5 athletes exercise?
- void mainprog()
- {
- athlete Julia, Andrea, Ricardo, Andy, Michael;
- JumpJack(Julia);
- JumpJack(Andrea);
- JumpJack(Ricardo);
- JumpJack(Andy);
- JumpJack(Michael);
- }
or
- void mainprog()
- {
- athlete Guy[5]; // declares an array of 5 athletes
- for (int which=0; which<=4; which++)
- {
- JumpJack(Guy[which]);// each athlete does a jumpjack
- }
- }
|