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
Is there any difference between int [] a and int a [] in c++?
Why is it necessary to use a reference in the argument to the copy constructor?
what is COPY CONSTRUCTOR and what is it used for?
I want to write a C++ language program that: 1. Reads in the size of a square from the screen; 2. Prints a hollow square of that size out of “-“, “|” and blanks on screen; 3. Prints the same hollow square onto a text file. The program should work for squares of all side sizes between 1 and 20.
What is the full name of logo?
Can we use struct in c++?
What is stream and its types in c++?
Describe new operator and delete operator?
Should a constructor be public or private?
Explain abstraction.
Describe exception handling concept with an example?
explain the reference variable in c++?
What is an orthogonal base class in c++?
What is the difference between struct and class?
What's c++ used for?