If a function uses call by reference then it receives

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: trevle: / h ucin eevs he aus / asrn,aohrsrn,ada itgr / tig nte tig n n nee; / teevle aenmd'1,'2,ad'tr'i tefnto isl / hs aus r ae s' s' n sat n h ucin tef lntOOelp=oelpeghipt,ipt,satfvra) eghfvra vraLnt(nu1 nu2 trOOelp; Functions can also use call-by-reference. If a function uses call-by-reference, then it receives not just the value of an argument but also the memory location of the original variable. All variables keep track of their memory location so they know where their value is stored in memory. When a variable is updated or assigned, the value in the variable's memory location is changed. When a function uses call-by-reference, it also has access to the memory locations that the original variables (in the calling function) used. So the function can change the values in those memory locations. Here is an example of a function that uses call-by-reference. It's the "increment" function, which means it takes an integer parameter and increases that integer by one. #nld <otem icue isra> uig...
View Full Document

This note was uploaded on 05/23/2013 for the course CSE 203 taught by Professor Eckroth during the Spring '10 term at Ohio State.

Ask a homework question - tutors are online