References in C++
References in C++ are very important as they can help you significantly reduce the running time of your code. A reference is simply another name to the same data value. For example, here x_ref is a integer reference to x : int x = 10; int & x_ref = x; // reference initialization cout<<x_ref; // x_ref and x are same, i.e. 10 x_ref = 20; cout<<x; // x is now 20 A reference is declared by using the & sign [the & sign is also used to get memory location of a variable]. It is necessary to initialize a reference at the time it is declared. It is because you cannot have NULL references, so you need to initialize an explicit value to which declared reference is a reference to. When you modify a reference, the original value also changes. Another example, string s = "Hello, this is original string"; string &x = s; x = "Modified string"; cout<<x; // outputs Modified string cout<<s; // outputs Modi...