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
Write a program which is required to process the time of a clock in hours and minutes, entered from the keyboard. With this program, there are two requirements for any data entered by a user: 1. The data must be of the correct type (in this case, two ints). 2. The data must be in the correct range: this means that, for the minutes, negative numbers and any number above 59 must be rejected; for the hours, negative numbers and any number above 23 must be rejected. Output error message for invalid data input. Output the time one and a half hour after the time input. i.e. Hour: 22 Min: 32 One and a half hour after 22:32 is 00:02
Explain about Garbage Collector?
How can we access protected and private members of a class?
What is a block in c++?
How would you obtain segment and offset addresses from a far address of a memory location?
What is vector string in c++?
Why is main function important?
What is exception handling? Does c++ support exception handling?
Is dev c++ free?
If a base class declares a function to be virtual, and a derived class does not use the term virtual when overriding that class, is it still virtual when inherited by a third-generation class?
Explain selection sorting?
Describe the process of creation and destruction of a derived class object?
What is while loops?
How can you quickly find the number of elements stored in a static array? Why is it difficult to store linked list in an array?
what is Loop function? What are different types of Loops?