Go4Expert (http://www.go4expert.com/)
-   C++ (http://www.go4expert.com/forums/cpp/)
-   -   Reference and Pointer (http://www.go4expert.com/forums/reference-and-pointer-t5881/)

kaustubh 15Aug2007 09:17

Reference and Pointer
Reference is the other name given to the same variable. Pointer is new variable created which can contain address of another variable.

Try an experiment


# include<iostream>
using namespace std;
int main()

int i = 90; // variable
int &j = i;  // reference
int *P;  //  pointer
P =&i;

cout<<endl<< "address of variable :i" <<&i;

cout<< endl << "address of reference: j" <<&j;
cout<<endl<<"address of pointer : P"<<&P;
return 0;
 address of variable i: 0012FEDC
address of reference j: 0012FEDC
address of pointer p: 0012FEE0

so you see the address of i and reference j is same , address of pointer P is different.

shabbir 15Aug2007 10:06

Re: Reference and Pointer
You have same post in Difference between Pointers and Reference in C++ thread. Thread closed.


All times are GMT +5.5. The time now is 15:55.