What are References in C++ and OOPS ? How are they used ?

A reference means an alias. It is an alternative name to an object. An object can have multiple references. However the most important use of references is to pass arguments to function and return values for functions as well as for overloaded operators. E.g. consider a reference for a variable x created as x1.int x = 10;int &x1 = x; To make sure that the reference denotes an object it has to be initialized. Once initialized the value of a reference cannot be changed. In order to get a pointer to the object denoted by the reference x1 we can write it as &x1; One of the important uses of reference is to pass an object to a function as a reference so that the function can change the value of that object. e.g. void swap (int &a, int &b){    int tmp = a;    a = b;    b = a;}void main (){    int x = 10, y = 12;    swap (x, y );} Since x and y are passed by reference to the function swap their values get actually swapped.