Short Note On Reference Operator in C++

No comments

Reference Operator :-  Decide the normal declaration variable C++ allows ‘references’ to be declared as synonyms for variables. A reference to a variable is like an alias; the variable name and the reference name can both be used in statements,which effect the variable  –

   int abc;
   int & ref = abc;

In the above example a variable abc is defined, which due to its initialization address the same memory location,which abc occupies. In the definition of ref,the reference operator & indicates that ref is not itself an integer but a reference to one. The two statements  –

       abc ++;
       ref ++;

Above the example have same effect.

No comments :

Post a Comment

Subscribe

Milan Panda
Admin
About Me | Contact
Copyright 2023-2024 © Programming1011 . 🎀 Developed and Design By- Milan Panda. Happy Holi All Of You 🎀