Slimelite BBS

passing different size ar

Back to EMULATE

From Blaise Gassend · 1996-04-07 05:06 · #73659 in EMULATE

Salut Tom,

Le 25 Mars 1996  19h42 Tom Chantry disait  Tous:

TC>Subject: passing different size arrays

TC>   is it possible to have one function, which can accept different sizes
TC>   of mulit-dimenstuonal arrays, ie.

TC>   What would be the function parameter in this case?

What you want can be done. Instead of passing the array, you should pass
a pointer to it which comes out to the same thing. You also have to pass
the size of the array so thet the function knows what it is working
with:

voit Display(int num[10])
{
   int i;
   for (i = 0; i < 10; i++) cout << num[i] << "\n"
}

becomes:

voit Display(int *num, size)
{
   int i;
   for (i = 0; i < size; i++) cout << num[i] << "\n"
}

Amicalement
Blaise

 * SLMR 2.1a * 640K ought to be enough for anybody. -Bill Gates, 1981

--- FMail 1.02+   
 * Origin: LoLo BBS - Nice France (+33)9392.4752 - (2:323/23)