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

How can you link a c++ program to c functions?

624


Explain the difference between struct and class in terms of access modifier.

699


Write bites in Turbo c++ Header ("Include") Files.

690


How long it will take to learn c++?

618


Explain stack unwinding.

642






Define token in c++.

717


What is data type in c++?

561


Search for: what is pair in c++?

595


How can you specify a class in C++?

802


What is prototype in c++ with example?

568


What is the use of lambda in c++?

583


Describe friend function & its advantages.

717


What is the main purpose of c++?

551


What information can an exception contain?

669


What is the difference between passing by reference and passing a reference?

562