Pregunta de entrevista de Esri

What is the difference between a reference and a pointer?

Respuestas de entrevistas

Anónimo

21 de ago de 2009

There are additional differences. I would not say that they are same because: 1. References cannot be null, whereas pointers can; every reference refers to some object, although it may or may not be valid. 2. A reference always identifies a valid object in the memory. 3. References cannot be uninitialized. Because it is impossible to reinitialize a reference, they must be initialized as soon as they are created. In particular, local and global variables must be initialized where they are defined and references which are data members of class instances must be initialized in the class's constructor. 4. Once a reference is created, it cannot be later made to reference another object; we can say it cannot be reseated. This is often done with pointers.

6

Anónimo

26 de ago de 2009

Thank you for elaborating. I didn't go into the full details for the sake of brevity. Your answer is definitely more helpful and correct than the one I originally wrote.

Anónimo

13 de mar de 2009

They are the same, but you can't reassign a reference and you have to de-reference a pointer to get to the data.