Question d’entretien chez Esri

What is the difference between a reference and a pointer?

Réponses aux questions d'entretien

Utilisateur anonyme

21 août 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

Utilisateur anonyme

26 août 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.

Utilisateur anonyme

13 mars 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.