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