C++ examples for Data Type:Reference
Initializing and using a reference.
#include <iostream> int main(int argc, const char* argv[]) { int x = 3;//from w w w.j a v a 2s. co m int& y = x; std::cout << "x = " << x << std::endl << "y = " << y << std::endl; y = 7; // modifies x std::cout << "x = " << x << std::endl << "y = " << y << std::endl; return 0; }