References in c++

This is a part of c++ language not in c.

-> References are the nick name or alias’s given to a variable.

//simple code to explain References
int main()
     int a =10;
    int &r=a;
    //printing the values of a and r
    cout<<a;   ---------------------------------10
    cout<<r   -----------------------------------11
     cout<<a;    --------------------------------11

why does we need a reference or a nickname to a variable.
-> This is very useful feature in c++ for parameter passing.


Related post

Leave a Reply

Your email address will not be published. Required fields are marked *