Reference and Pointer

kaustubh's Avatar, Join Date: Aug 2007
Go4Expert Member
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

Code:
# 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;
}
OUTPUT:
 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's Avatar, Join Date: Jul 2004
Go4Expert Founder
You have same post in Difference between Pointers and Reference in C++ thread. Thread closed.

http://www.go4expert.com/showthread.php?p=16427