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 ios :: in in c++?

808


What is the c++ code?

782


What does the linker do?

781


Can I make ios apps with c++?

758


What is endl?

862


What is the need of a destructor?

846


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

815


Is it possible to provide default values while overloading a binary operator?

988


What is exception handling? Does c++ support exception handling?

774


Explain the pure virtual functions?

827


Explain function overloading and operator overloading.

803


What is a float in c++?

725


What are friend classes?

823


what is data encapsulation in C++?

779


What relational operators if statements in c++?

872