Passing expression as a parameter in Call by reference

Posted by darkie15 on Stack Overflow See other posts from Stack Overflow or by darkie15
Published on 2010-06-12T07:28:43Z Indexed on 2010/06/12 7:33 UTC
Read the original article Hit count: 285

Filed under:

All,

When we are passing an expression as a parameter, how does the evaluation occur? Here is a small example. This is just a pseudocode kind of example:

f (x,y)
{
    y = y+1;
    x = x+y;
}
main()
{
    a = 2; b = 2;
    f(a+b, a)
    print a;
}

When accessing variable x in f, does it access the address of the temp variable which contains the result of a+b or will it access the individual addresses of a and b and then evaluate the value of a+b

Please help.

Regards, darkie15

© Stack Overflow or respective owner

Related posts about parameter-passing