Previous Lecture | Lecture 9 | Next Lecture |
Lecture 9, Thu 02/06
Arrays and Pointers
Topics
This lecture and many of the coming lectures require that we understand how our programs interact with computer memory. This is not required to understanding some of the programming constructs like arrays and pointers but is crucial for reasoning about weird program behavior and debugging. So, we will begin with a model of computer memory and then delve into C++ arrays and pointers
C++ arrays
- Intro to lab04
- C/C++ arrays are like lists in Python and Arrays in Java. We will discuss the differences between these.
- Declaring and initializing arrays in C++
- char arrays, C-strings and string literals
- Basic operations on C-Strings
- String class objects and methods (similarities and differences with c-strings)
- Iterating through arrays using the C++11 range based for loops
- Passing arrays to functions
- Array pitfalls: out of bound array access