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
What is vcredist_x86 exe?
Is visual c++ a compiler?
Does visual c++ 2017 replace 2015?
Is it ok to uninstall microsoft visual c++?
Difference between getmessage, postmessage & peakmessage.
What is microsoft visual c++ 2013 redistributable package x64?
What is cwinthread class?
What is vc++ redistributable?
How do I fix microsoft visual c++ 2015 setup failed?
Where can I find microsoft visual c++ on my computer?
What is iunknown? Explain some of commonly used methods provided by iunknown.
hello sir i need movie editing and mixing software .where it is available and what is the site address
Where can I find microsoft visual c++?
What is microsoft visual c++ 2008 redistributable?
What is a thread (VC++) and state the difference between Cmutex and Csemaphone?