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
Refer to a name of class or function that is defined within a namespace?
To which numbering system can the binary number 1101100100111100 be easily converted to?
Can we declare a base-class destructor as virtual?
Why is c++ difficult?
write a program that withdrawals,deposits,balance check,shows mini statement. (using functions,pointers and arrays)
Write a function to find the nth item from the end of a linked list in a single pass.
How would you call C functions from C++ and vice versa?
What is c++ good for?
Explain the difference between realloc() and free() in c++?
What is a try block?
What is the use of turbo c++?
What is the type of 'this' pointer? When does it get created?
How can I improve my c++ skills?
How can you link a c program with a c function?
How can you prevent accessing of the private parts of my class by other programmers (violating encapsulation)?