home *** CD-ROM | disk | FTP | other *** search
/ C by Discovery (4th Edition) / C_By_Discovery_4th_Edition.tar / C_By_Discovery_4th_Edition / CH_12 / 682.jpg < prev    next >
Joint Photographic Experts Group Image  |  2013-12-12  |  627KB  |  2550x3300
Labels: book | reckoner
OCR: 682 Chapter Discovering C++ void swi tchxz int *xp, int *zp int tmp *xp; xp zp The call to switchxzO would be swi tchxz &x You needed to pass in the addresses of and as actual parameters In the func- tion code, the pointers xp and zp needed to be dereferenced to access the variables and and change their values. simpler version of swi tchxz) follows. It is written in ++ and uses ref erence parameters.: void swi tchxz( int& alias, int& alias int tmp lias alias, tmp, The parameters are both passed by reference It is unnecessary to dereference the formal parameters inside the function code The call to this version of swi tchxz in + is simpler too: swi tchxz The actual parameters are X and themselves instead of pointers or addresses of the variables. Closer Look In reality, ++5 implements passi ...