What is the difference between Pointer and a Reference?
When you would use them?

Answers were Sorted based on User's Feedback



What is the difference between Pointer and a Reference? When you would use them?..

Answer / srihariraju

A reference just renames a memory location for the
reader/programmer. Its more like renaming a constant with
#define. The reference does not really 'contain' the
address, instead the comiler *could* just substitute the
address for the reference at the assembly code level.

A pointer is a variable (it 'must' have a memory location
of its own (barring odd compiler tricks)) that *can* be
used like a reference or it can point to nothing (NULL) (a
reference cannot do that) and a pointer can get new memory
from the os (new command) while a reference must 'point' to
existing memory.

Is This Answer Correct ?    14 Yes 0 No

What is the difference between Pointer and a Reference? When you would use them?..

Answer / man

Reference is alias of a variable i.e. a constant pointer
which reference to a variable and can not be NULL.
You can not can get the address of ref. They are used as a
variable.

Pointers are variale that hold address of variable and can
be NULL. And can point to any number of variable.

Is This Answer Correct ?    3 Yes 0 No

What is the difference between Pointer and a Reference? When you would use them?..

Answer / vinay bondade

A Pointer is not a condt pointer unless you define it in
that way,but a referrence on the contrary is a const
pointer by default and adding to this implementation it is
deferrenced automatically.

Is This Answer Correct ?    1 Yes 3 No

What is the difference between Pointer and a Reference? When you would use them?..

Answer / nav

pointer are variable and no need to be initilise,but
refrence is the rename of variable and must be
initilise.pointer also assign null value but reference not
assign null value.

Is This Answer Correct ?    1 Yes 3 No

Post New Answer

More C++ General Interview Questions

Can create new c++ operators?

0 Answers  


What is a type library?

0 Answers  


What is a far pointer? where we use it?

0 Answers  


Is structure can be inherited?

5 Answers   HP, ST Micro,


What is private public protected in c++?

0 Answers  


A mXn matrix is given and rows and column are sorted as shown below.Write a function that search a desired entered no in the matrix .with minimum complexity 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16

0 Answers  


What are the effects after calling the delete this operator ?

0 Answers  


In the derived class, which data member of the base class are visible?

0 Answers  


What is a template in c++?

3 Answers  


What do the keywords volatile and mean mutable?

0 Answers  


Memory is not a constraint. In a single iteration(NOTE: you can't go back), how will you find out the 10th last node/item in a linked list.

16 Answers   BNB, FDS, Goldman Sachs, Nagarro,


How will you call C functions from C ++ and vice-versa?

0 Answers   Agilent, Tavant Technologies, Thomson Reuters, Verifone,


Categories