Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int function(int z) // z is a parameter to the function 'function'
- {
- int x, y; // x, y are local variables to the function 'function'
- x = y = 10;
- z = x + y;
- return z; // returns the VALUE of z only.
- }
- // x, y, and z no longer exist. They're gone. Only the VALUE of z is returned to the caller. z itself is destroyed.
- int function2(int a) // a is a parameter to the function 'function2'
- {
- int x, y; // x, y are local variables to the function 'function2'. They are NOT, I repeat, NOT the same x and y as in function2. These variables are now ENTIRELY DIFFERENT EVEN IF THEY HAVE THE SAME NAME, because they are in a different set of { }s.
- x = y = 10;
- a = x + y;
- return a; // returns the VALUE of a only.
- }
- // a, x, and y no longer exist to us anymore. They're gone. Only the VALUE of a is returned to the caller. a itself is destroyed.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement