What is the difference between reference type and pointers.
Answer Posted / k govind
In addition to the previous answer given in Answer #1,
namely References must point to valid objects at the time
of declaration, references also has the following
limitation.
Once a reference is assigned, there's no way you can modify
the reference. However for a pointer type, variable
assignment is legal.
e.g.,
int i, j;
int *pi, *pj;
pi = &i; // pointer to i
pj = &j; // pointer to j
int &k = i; // reference to i
pi = pj; // pi no longer points to i, instead
// it is now pointing to j
k = j; // The reference k is still with i, it is only
// the value of i that is now modified. i is
// assigned the value of j
| Is This Answer Correct ? | 3 Yes | 0 No |
Post New Answer View All Answers
Differentiate between a template class and class template in c++?
What is difference between class and structure in c++?
What is iostream in c++ used for?
Can a class be static in c++?
What do you mean by static variables?
What are the advantages of prototyping?
What is array in c++ example?
What is the protected keyword used for?
What is the best c++ compiler?
What do you mean by storage classes?
Why is c++ is better than c?
What do you understand by pure virtual function? Write about its use?
which of the following is not an secondary constant a) array b) real c) union
Difference between pointer to constant and constant pointer to a constant. Give example.
Explain the isa and hasa class relationships.