Pointers and References
Pointers and references are variables that contain the "address" in memory of a piece of data, rather than the actual data. For a real-world example, consider your name in the class grade book... Is this name the actual you (the human body)? NO. Does your name provide information that allows the professor to "refer to" (or reference) you? YES! Can there be multiple names that all refer to you? Of course. The teacher can call you Mr. Doe, your friends can call you Homer, and your mom can call you Sparkle. These names are all "references" to the same data (you).
Pointers and References Pointers and References: Analogy
Imagine a card catalog in a library. When you know the name of a book, you don't know WHERE in the library it is. To find the book, first you go to the card catalog, and the card catalog POINTS you to the book (or, in other words, is a reference to the book).
Alternatively, you may go to the computer and search for the book by its name or by its author. Either way, you will get a "reference" to where the book is in the library. Now you have two references, but they both "point to" the same thing.
This is how some data is stored in a computer program. Instead of keeping the data directly in the memory bucket, the memory bucket contains a "pointer" to the actual location of the…