What is the difference between reference type and pointers.

Answer Posted / manoj kumar kar

Difference 1>
Reference must point to valid objects at the time of
declaration where pointer need not point to valid objects
at the time of declaration means
int nvalue=5;
int &rnvalue; //This is invalid.
int &rnvalue=nvalue; //This is valid.

But
int *rnvalue; //This is valid.
rnvalue=&nvalue;
Difference 2>
Pointer is a variable which holds the address of another
variable.
But Reference is another name of the same variable.

Is This Answer Correct ?    18 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the rule of three?

564


What is a tree in c++?

557


In what situations do you have to use initialization list rather than assignment in constructors?

627


What is buffering in c++?

580


What is virtual destructor ans explain its use?

599






What are the advantages of pointers?

593


How is modularity introduced in C++?

763


What is the use of namespace std in C++?

610


How new/delete differs from malloc()/free?

609


Can a constructor be private?

573


What is an undefined behavior and sequence points

559


Declare a class vehicle and make it an abstract data type.

531


what is C++ exceptional handling?

620


To which numbering system can the binary number 1101100100111100 be easily converted to?

602


What is constructor in C++?

624