doubt ampersand
#3

The ampersand means that the argument is to be passed as a reference, not as a value. If you pass arguments by value (the default) then the original value of the variable will not change. If you pass arguments by reference then they will. For example:
pawn Код:
new a = 42;

stock byRef(&value)
{
    value++;
}

byRef(a);
printf("%d", a);
Will print 43. Whereas:

pawn Код:
new a = 42;

stock byVal(value)
{
    value++;
}

byVal(a);
printf("%d", a);
Will still print 42.
Reply


Messages In This Thread
doubt ampersand - by Rodrigo. - 15.09.2012, 23:36
Re: doubt ampersand - by BadgerLedger - 15.09.2012, 23:40
Re: doubt ampersand - by Vince - 15.09.2012, 23:43
Re: doubt ampersand - by Rodrigo. - 15.09.2012, 23:47

Forum Jump:


Users browsing this thread: 1 Guest(s)