Short Note On Reference Operator in C++
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.
Subscribe to:
Post Comments
(
Atom
)
No comments :
Post a Comment