referencing and dereferencing operators in C++

referencing operator (रेफेरेंसिंग ऑपरेटर):-
The address-of operator (&) is also called referencing operator. It operates on a variable, and returns the address of the variable. 
एड्रेस ऑपरेटर (&) को रेफेरेंसिंग ऑपरेटर के नाम से भी जाना जाता है। यह एक वेरिएबल पर लागु किया जाता है एवं उसका एड्रेस प्रदान करता है।   
Syntax:-
&variable_name

Example:-
int n=10,*p;
p=&n; //referencing  

dereferencing operator(डीरेफेरेंसिंग ऑपरेटर):-
The indirection operator (*) is also called dereferencing operator. It operates on a pointer, and returns the value stored in the address hold by the pointer variable. 
इनडायरेक्शन ऑपरेटर (*) को डीरेफेरेंसिंग ऑपरेटर के नाम से भी जाना जाता है। यह एक पॉइंटर वेरिएबल पर लागु किया जाता है एवं उस पॉइंटर में रखे वेरिएबल एड्रेस पर रखी गयी वैल्यू प्रदान करता है।   
Syntax:-
*pointer_name

Example:-
int n=10,*p;
p=&n; //referencing  
cout<<"value of n="<<*p<<endl; //dereferencing

C++ Program:-
#include<iostream.h>
int main(){
int n=10,*p;
p=&n; //referencing  
cout<<"value of n="<<*p<<endl; //dereferencing
return 1;
}

No comments:

Post a Comment