Difference on passing by reference?
#5

pawn Код:
public OnFilterScriptInit()
{
   new
      a = 5,
      b = 5,
      c = 5,
      d = 5;
   something(a,b,c,d);
   printf(#%d - %d - %d - %d,a,b,c,d);
}

something(a , &b , c)
{
   a = 1;
   c = 2;
   b = a + c;  
}
// it should output : 5 - 3 - 5
The variable passed by reference won't have his value modified, since his value is passed to the function. Basically, it allows the function to change his value.

Again, i recommend you to stop being lazy and read more the pawn-lang.pdf
Reply


Messages In This Thread
Difference on passing by reference? - by TheArcher - 02.09.2012, 15:25
Re: Difference on passing by reference? - by TheArcher - 02.09.2012, 15:49
Re: Difference on passing by reference? - by leonardo1434 - 02.09.2012, 15:53
Re: Difference on passing by reference? - by TheArcher - 02.09.2012, 15:57
Re: Difference on passing by reference? - by leonardo1434 - 02.09.2012, 16:40
Re: Difference on passing by reference? - by TheArcher - 02.09.2012, 20:18
Re: Difference on passing by reference? - by TheArcher - 03.09.2012, 07:09
Re: Difference on passing by reference? - by Babul - 03.09.2012, 07:28

Forum Jump:


Users browsing this thread: 1 Guest(s)