------------------------------------------------------------------------------
MC logo
Pointers and References
[^] CSc 220 Home
------------------------------------------------------------------------------
[Introduction] [Boolean and Control] [Functions] [Arrays and Pointers] [Dynamic Arrays] [Array Errors] [Command Array] [Standard Containers] [Structs and Classes] [Automatic Pointer] [Multi-File Programs] [Copying Objects] [Templates] [Inheritance] [Plain C I/O] [Type Odds And Ends] [Plain C Strings] [File I/O]
[Array Echo] [Basic Pointers] [Swap Using Pointers] [Arrays and Pointers] [Array Passing] [Integer Select Sort] [Integer Quick Sort] [Integer Library Sort] [Pointers and References]
Pointers come from plain C, and references were added by C++. They have both similarities and differences which can be terribly confusing. This page is supposed to point out some of these, in the faint hope that it will make some sense. Pointers are the more general facility. Anything you can do with a reference, you could re-write to do with a pointer. Some pointer jobs cannot be done with a reference.

If something can be written using either pointers or references, both versions will likely produce essentially the same machine code. The source code differences are artifacts of the language design and semantics.