CyberSlug Rules!

Beginner Programming CMPS060

Prof. Paulo Franca

Home

Syllabus

Login

Objects

Download

Staff only

Use as arguments.

  • an array can be used as argument to a function;
  • an array element can be used as an argument to a function;

to receive an array as argument, the function must declare it:

void jumpjack(athlete eachone[10], int howmany_athletes)

{

for (int i=0;i<howmany_athletes;i++)

{

eachone[i].ready();
eachone[i].up();
eachone[i].ready(0.);

}

}

to receive an array element, no special declaration is needed; the element is of type athlete above.

void jumpjack(athlete one)
{
}

could be invoked with:

jumpjack(eachone[5]);