What is the difference between pointer and reference?

Answer Posted / mritunjay rai

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 ?    4 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is splitter window in vc++?

788


How do I uninstall visual c++?

637


how to declare and populate an array of checkBoxes

778


Explain pointer to the constant and constant pointer?

586


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

622






How do I reinstall microsoft visual c++?

595


Do I need microsoft visual c++?

638


How do I remove microsoft visual c++ 2015 redistributable?

658


Do I need microsoft visual c++ 2005 redistributable on my computer?

732


What is microsoft visual c++ 2005 redistributable?

669


What is vcredist_x86 exe?

681


Is it safe to uninstall microsoft visual c++ 2008 redistributable?

651


How to create a DLL in C++.net 2005 which we can use in VB 6.0 application ?

1849


Do I need microsoft visual c++ on my computer?

679


Do you need microsoft visual c++?

695