CMPT 115 Lecture 3: references-notes
Document Summary
Notes written by michael horsch, mark eramian, ian mcquillan, lingling jin, and dmytro dyachuk. In c++, all variables have: a type: decided by the programmer, a name: decided by the programmer, a value: determined by the program, an address: determined at runtime by the os. Normal variable declaration mynum 7; memory looks like address contents. Advanced programming techniques that make use of addresses: work with compound data without copying the data (e. g. , arrays, records, organize large collections, make some calculations more e cient. Three new concepts: a new kind of type: reference (also called address ), an operator (&) to acquire the address of a variable, an operator (*) to use the address of a variable. These seem easy at rst, but these are the main source of program failure. In pseudocode and c++, if var is a variable name, then the expression &var is the address of that variable.