home *** CD-ROM | disk | FTP | other *** search
/ C Programming Starter Kit 2.0 / SamsPublishing-CProgrammingStarterKit-v2.0-Win31.iso / tybc4 / refvar1.cpp < prev    next >
C/C++ Source or Header  |  1993-03-27  |  511b  |  24 lines

  1. /*
  2.   C++ program that demonstrates reference variables
  3. */
  4.  
  5. #include <iostream.h>
  6.  
  7. main()
  8. {
  9.   int x = 10;
  10.   int& rx = x;
  11.   // display x using x and rx
  12.   cout << "x contains " << x << "\n";
  13.   cout << "x contains (using the reference rx) " 
  14.        << rx << "\n";
  15.   // alter x and siplay its value using rx
  16.   x *= 2;
  17.   cout << "x contains (using the reference rx) " 
  18.        << rx << "\n";
  19.   // alter rx and display value using x
  20.   rx *= 2;
  21.   cout << "x contains " << x << "\n";
  22.   return 0;
  23. }
  24.