C++ Programming - References - Discussion
Discussion Forum : References - General Questions (Q.No. 8)
8.
Which of the following statements is correct?
- A reference is not a constant pointer.
- A referenced is automatically de-referenced.
Discussion:
9 comments Page 1 of 1.
Manisha said:
8 years ago
I do not understand de-referenced. Please explain
Segaa said:
8 years ago
Reference cannot be de-referenced, it's an alias of a variable name not requiring any "de-referencing", so the question is incorrect.
Legndery said:
9 years ago
Reference behave like const pointer.
When a value of a pointer is needed it is explicitly dereferenced.
like,
Object *p = new object;
(*p).aMethod();
But in case of reference this is not needed.
object &p = someobj;
p.aMethod();
When a value of a pointer is needed it is explicitly dereferenced.
like,
Object *p = new object;
(*p).aMethod();
But in case of reference this is not needed.
object &p = someobj;
p.aMethod();
(1)
Vinodhini said:
1 decade ago
When a reference will be de-referenced? What is the scope?
Siva said:
1 decade ago
What is mean by de-referenced?
Anton said:
1 decade ago
1 is correct, 2 is unclear. The correct answer is A.
Yashaswi Bharadwaj said:
1 decade ago
@Jarek: If it is not a constant pointer (though it acts in that way), then option should be the answer, right?
Ann said:
1 decade ago
How can reference be automatically de-referenced?
Jarek Fuks said:
1 decade ago
Reference bechaves like constant pointer but it is NOT a constant pointer: e.g: int & ref; *ref is incorrect
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers