What is the difference between pointer and reference?

Answer Posted / noopur sharma(m.c.a. r.u)

1)it is not necessary to intialize a pointer at the time of
declaration.like:int a=10; int *p=&a;
u can also do int a=10; int *p; p=&a;
but in the case of reference it is necessary to
intialize a ref.at the time of declaration.like: int
&a=10;bcoz ref.is the secondname(aliase)for an object.means
it always refere an object so it's necessary to initialize
it.
2)u can assign NULL to a pointer.like int *p=NULL; but u
can't assign NULL to a reference.like int
&P=NULL//incorrect.
3)u can create array to a pointer but u can't create
array to a ref.
4) u can use pointer to pointer.but u can't use ref.to ref.
5) pointer is a new variable that contain the address of
another variable.but ref. is a second name (aliase) of the
same variable.
6)to store pointer we require extra memory.but for
reference we don't require extra memory.

Is This Answer Correct ?    12 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is microsoft visual c++ redistributable and do I need it?

540


How do I get rid of microsoft visual c++ runtime library error?

670


hello sir i need movie editing and mixing software .where it is available and what is the site address

1729


Can I delete old microsoft visual c++?

551


What is difference between c++ and visual c++?

554






What is microsoft visual c++ used for?

561


What is iunknown?

558


How do I uninstall visual c++?

546


In which Way invoke context-sensitive help inside the editor?

1786


Is visual c++ a compiler?

558


Do I need all the microsoft visual c++ redistributable?

528


What is cmutex? How can we use it?

573


What is cmutex?

585


What is visual c++ 2008 redistributable x64?

556


Difference between getmessage, postmessage & peakmessage.

611