What is the difference between Pointer and a Reference?
When you would use them?
Answer Posted / 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 |
Post New Answer View All Answers
How many types of modularization are there in c++?
What is the difference between a template and a macro?
Does c++ have finally?
What is the difference between function overloading and operator overloading?
what is Member Functions in Classes?
What is std :: flush?
Describe private, protected and public – the differences and give examples.
List the features of oops in c++?
Assume studentNames and studentIDs are two parallel arrays of size N that hold student data. Write a pseudocode algorithm that sorts studentIDs array in ascending ID number order such that the two arrays remain parallel.
Is ca high or low level language?
What are the different types of comments allowed in c++?
What is meaning of in c++?
Explain rethrowing exceptions with an example?
What is the best free c++ compiler for windows?
What is the cout in c++?