C++ examples for Data Type:Reference
References must be initialized
#include <iostream> int main(int argc, const char* argv[]) { int x = 3;//from w w w. ja v a 2 s . c o m //int& y; // Error y must be initialized int& y = x; std::cout << "x = " << x << std::endl << "y = " << y << std::endl; y = 7; std::cout << "x = " << x << std::endl << "y = " << y << std::endl; return 0; }