First page Back Continue Last page Graphics
Reference Variable (cont.)
A SINGLE variable with TWO names.
Must be initialized when defined.
Most often use is a function parameters.
Study figure 8.2 and be sure you see how reference variables implement “pass by reference”.
- int times(20); // in main
- grumpy(times) // “ “
-
- void grumpy(int & x) // in function
- { x = 12; } // changes value in times
Practice: swaps.cpp in prata