In-class notes for 09/28/2018
CS 251 (SD), Fall 2018
Reading questions
Some uses for pointers:
Data structures, e.g., array of
Dog
Linked structures; loops, functions, etc.
Dynamic allocation
References vs. address operators
L-values (left/location) vs. R-values (right)
Spec for=
operator.=
(Assignment operator)-
2 arguments: An L-value (memory location) of type T, and a value of that type T
State change: The value arg2 is assigned to the location arg1.
Return: Type T, the value that was assigned (i.e., arg2).
types vs operators (functions with specialized syntax)
Puzzles
HW10
Upcoming topics
Dynamically allocated memory
Preview: 3 ways to allocate memory (i.e., set aside for a particular use, such as a variable.
local -- allocated in a stack frame when the program runs (runtime).
Includes local variables (e.g., withinmain()
or another function), function argumentsglobal -- allocated at compile time. Any memory allocated outside of a function.
dynamic -- allocated at runtime in the heap (not part of a stack frame, though a local variable may point to it)
struct
data structures
To study for quiz
Arrays -- coding, memory diagrams
Reference arguments -- coding, memory diagrams
Strings as null(byte)-terminated arrays of characters -- coding, memory diagrams