home *** CD-ROM | disk | FTP | other *** search
- /*
- C++ program that demonstrates reference variables
- */
-
- #include <iostream.h>
-
- main()
- {
- int x = 10;
- int& rx = x;
- // display x using x and rx
- cout << "x contains " << x << "\n";
- cout << "x contains (using the reference rx) "
- << rx << "\n";
- // alter x and siplay its value using rx
- x *= 2;
- cout << "x contains (using the reference rx) "
- << rx << "\n";
- // alter rx and display value using x
- rx *= 2;
- cout << "x contains " << x << "\n";
- return 0;
- }
-