Passing schemes

So I have this code, and there is an question that made me confused.

What parameter passing scheme is used for each argument in foo( )?

Can someone explain to me this, please?

Thanks.

1
2
3
4
5
6
7
8
  void foo (  int x,   float & y,   char z[ ],  float *w)
{
	x *= 3;
        y -= 3.0;
        z[0] = 10.0;
       *w /= 1.5;
}
Last edited on
x is pass by value ._.)a it'll copy the value from given parameter
y is reference ._.) I don't quite understand this one but if the variable y is changes the variable that given as parameter will also change
z[] used when you'll pass an array
w* pass by pointer, it'll copy an address of the parameters, and you can use it to pass an array too

Sorry if there's any mistake from my explaination
z is also "by pointer". In argument lists, []'s for the first dimension are the same as writing *.

Hence, char z[] == char * z.

Keep in mind that the pointer object itself is passed by value.

Can someone explain to me this, please?
Here you go.
http://www.cplusplus.com/faq/beginners/call-by/

Hope this helps.
Topic archived. No new replies allowed.