A reference can be attached to its referent only at the moment the reference is initialized. Not only that, C++ requires every reference initialization to have a referent. The following example initializes j to be an alias for i, but the initialization of k is illegal because reference k is not attached to an object. int main() { int i; int& j = i; #ifdef GENERATE_ERROR int& k; //ERROR: references must be initialized #endif } When a function receives a parameter by reference, the reference is initialized by being attached (bound) to the actual argument provided by the caller. |