What is difference between normal variable and reference variable in c++? tccicomputercoaching.com A reference variable is an alias, that is, another name for an already existing variable in C++. Once a reference is initialized with a variable, either the variable name or the reference name may be used to refer to the variable.
They can be used like normal variables. '&' operator is needed only at the time of declaration. Also, members of an object reference can be accessed with dot operator ('.'), For example, int amount =10; int rupees; rupees=&amount; cout<<"rupess"<< rupess; cout<<"amount"<< amount; output: rupess 10 amount 10 now we do any update in amount variable , it will affect also in rupees variable. Same for vice versa. for example, amount=amount + 20; cout<<rupess;